Web Forms :: Data Getting Corrupted While Uploading Using FtpWebRequest?

Dec 25, 2010

I am using :

FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader("testfile.txt");
byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();

For uploading images and songs to the server. But the file is getting corrupted on upload. Normal upload is getting error due to security reason and access issues.

Had to dwell on to ftp. But in this case, file is getting corrupted.

View 1 Replies


Similar Messages:

Web Forms :: How To Set Port Number When Using FtpWebRequest For Uploading Files To FTP

Jun 16, 2015

[URL]

Unfortunately I get an error while uploading:

Invalid URI: Invalid port specified. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UriFormatException: Invalid URI: Invalid port specified.

FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftp + ftpFolder + fileName);My FTP-address is:ftp://ftp.mydomain.dk:4001

View 1 Replies

Web Forms :: Files Getting Corrupted When Uploading Using FTP

Sep 20, 2015

I have followed tutorial at [URL] .....

The file does upload via ftp but it is corrupt when downloaded. I've tried uploading a jpg file.

View 1 Replies

Transfer Files With Ftp With Ftpwebrequest?

May 26, 2010

currently I'm working on this ftp transfer. [URL]

I have setup my server computers iis to have a ftp site on port 21 and transfering files works great. But I want to add ftp to a hosted site I got on the server and it's here where I get the problems with connecting. when I try to connect through the command promt I get unknown host error. I have changed the port and open it up in firewall. and even if I could connect how can I decide what folder I want to upload to?

View 3 Replies

.NET FtpWebRequest Not Returning DateTimeStamp Or FileSize?

Jun 4, 2010

I'm using FtpWebRequest to connect to an FTP server and I can use WebRequestMethods.Ftp.ListDirectoryDetails to list the directory details fine. However the response from the remote server has day, month and time but not year:

-rw-rw-rw- 1 user group 949 Jun 2 08:43 Unsubscribes_20100602.zip
-rw-rw-rw- 1 user group 1773 Jun 1 06:48 export_142571709.txt
-rw-rw-rw- 1 user group 1773 Jun 1 06:50 export_142571722.txt
-rw-rw-rw- 1 user group 980 Jun 1 06:51 export_142571734.txt

This is required for the application I'm writing so I tried to use WebRequestMethods.Ftp.GetDateTimestamp to get the datetimestamp for each file but the response is always empty. No exception is thrown.

try
{
FtpWebRequest ftp = (FtpWebRequest)WebRequest.Create(path);
ftp.Credentials = new NetworkCredential(_ftpUsername, _ftpPassword);
ftp.Method = WebRequestMethods.Ftp.GetDateTimestamp;
try
{
Stream stream = ftp.GetResponse().GetResponseStream();
StreamReader sReader = new StreamReader(stream);
return sReader;
}
catch (Exception exp)
{
throw new Exception(String.Format("An error occured getting the timestamp for {0}: {1}<br />", path, exp.Message));
}
}

View 1 Replies

FTPWebRequest - Looking For Code To Pull The File Contents From The Client Computer, Not The Server?

Sep 21, 2010

I have written the following code that successful ftps a file to the proper location as long as the file exists on the server itself....

However, I need the code to pull the file contents from the client computer, not the server.

Here is the code:

[Code]....

When I deploy this application to my staging server and test it, it's looking for the files on the staging server...not my local computer.

View 1 Replies

Web Forms :: The State Information Is Invalid For This Page And Might Be Corrupted

Feb 23, 2010

I have been receiving this error despite of the fact i have set the following inside web.config

[Code]....

The error description is as follows: Source: System.Web Message: The state information is invalid for this page and might be corrupted. Stack Trace:

at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
at System.Web.UI.HiddenFieldPageStatePersister.Load()
at System.Web.UI.Page.LoadPageStateFromPersistenceMedium()
at System.Web.UI.Page.LoadAllState()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.pages_aspx.ProcessRequest(HttpContext context)in c:WindowsMicrosoft.NETFramework64v2.0.50727Temporary ASP.NET Files
oot2cade9c6ad55f41App_Web_pages.aspx.cdcab7d2.8ksggavg.0.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Data:System.Collections.ListDictionaryInternal Browser Capabilities
IP Address = 212.235.106.121
Type = Opera8
Name = Opera
Version = 8.00
Major Version = 8
Minor Version = 0
Platform = WinXP
Is Beta = False
Is Crawler = False
Is AOL = False
Is Win16 = False
Is Win32 = True
Supports Frames = True
Supports Tables = True
Supports Cookies = True
Supports VBScript = False
Supports JavaScript = True
Supports Java Applets = True
Supports BackgroundSounds = True
Supports ActiveX Controls = False
Browser = Opera
CDF = False
CLR Version = 0.0
ECMA Script version = 1.4
MSDOM version = 0.0
Supports tables = True
W3C DOM version = 1.0

View 3 Replies

App Having Viewstate Corrupted Every Few Minutes?

Jan 24, 2010

I'm having a problem with a web app I'm managing. Users starting receiving the following error occasionally:

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

The problem is that it's not a cluster - it's a single Windows 2003 server. After digging around, it appears that adding a machineKey section and some extra attributes to the Pages directive in my web.config resolves this error:

<machineKey validationKey='MACHINE KEY SNIPPED'
decryptionKey='DECRYPTION KEY SNIPPED'
validation='SHA1'/>
<pages validateRequest="true" enableEventValidation="false">

After changing these two things in my web.config, the error goes away, but now I have a new problem - Instead of an error that my viewstate is invalid, the app just "Forgets" who my user is, and sends them back to the login page. Now, the users are browsing through the application, and then they're unexpectedly sent to the login page, even after they've already been logged in for a few minutes. While I can't force this to happen, it usually happens within visiting 10-12 different pages, so pretty frequently.

I'd love a resolution to this - does anybody know what else might be causing the viewstate error on a single server, or what I can do to ensure that it's validated properly?

View 2 Replies

VS 2008 - Using Session Variables Get Corrupted

Jun 10, 2010

I have a situation where my session variables seem to get corrupted. I Page_Load I am calling 2 subs. Each of them fills a GridView with data from a table. I am saving the content of each Data.DataTable into Session Variables:

Get_Summary_Last_Completed_Shift()
code in sub:
mySqlDataAdapter.Fill(mySqlDataTable)
Session("mySqlDataTable1") = mySqlDataTable
GridView1.DataSource = mySqlDataTable
GridView1.DataBind()

Code:
Get_Petroleum_Disbursement()
code in sub:
mySqlDataAdapter.Fill(mySqlDataTable)
Session("mySqlDataTable5") = mySqlDataTable
GridView5.DataSource = mySqlDataTable
GridView5.DataBind()

After I call the 1st sub and I debug the session variable "mySqlDataTable1" contains all the data from the table. After I call the 2nd sub and I debug the session variable "mySqlDataTable1" has been changed and contains a mix of data from the 2 tables.

View 2 Replies

Sharepoint - Downloaded Files Corrupted?

Aug 5, 2010

I have written the following code to download a file from sharepoint. The downloded file works fine in only some machines. For others, it says that the file is corrupted. The issue is for MS Office and image files, however the PDF is not having any issues. We have identified the issue of corruption as due to the addition of a hexadecimal number at the top of the file contents. When it is removed, the file gets opened correctly. The hexadecimal character has been traced out to be representing the file size in bytes. Why this is happening only in some machines and how can we fix it?

private void DownloadFile()
{
SPListItem item = GetFileFromSharepoint();

[code]...

View 1 Replies

Publishing/uploading New DLL To IIS - Website Goes Down Whilst Uploading

Jan 15, 2011

When uploading a new DLL for a large web application (dll is around 1mb) IIS throws an error because the DLL is 'in-use', meaning the website is down while the DLL is being uploaded. Is there a way to stop this behaviour?

Also, although I am using Web Applications, not Web Sites, whenever I upload a new DLL it still takes a while for IIS to restart after a fresh upload. I thought this wait was generally only for websites as they need to be compiled by IIS, not Web Applications?

View 1 Replies

Xml - .NET To PowerPoint: File Gets Corrupted When Adding Image?

Oct 7, 2010

I have used this example when exporting data to PowerPoint:

I have modified the GenerateSlidesFromDB() method:

public void GenerateSlidesFromDB()
{
string slideName = @"C:UsersxDesktopoutput.pptx";
File.Copy(@"C:UsersxDesktopTest.pptx", slideName, true);[code]....

As you can see I overwrite the placeholder with "Test User", and it works like a charm.I need to add an image (as a placeholder) to this pptx-file. When I do that (and run the code again) I get a corrupted pptx-file?

Error message: PowerPoint removed unreadable content in output.pptx. You should review this presentation to determine whether any content was unexpectedly changed or removed.

Edit: If I try the original code (which is slightly modified since I dont have Adventureworks), I get some other kind of error message:

This file may have become corrupt or damaged for the following reasons: Third-party XML editors sometimes create files that are not compatible with Microsoft Office XML specifications.

The file has been purposely corrupted with the intent to harm your computer or your data. Be cautious when opening a file from an unknown source.

PowerPoint can attempt to recover data from the file, but some presentation data, such as shapes, text,and formatting, may be lost.

Do one of the following:If you want to recover data from the file, click Yes.If you do not want to recoverdata from the file, click No.

View 1 Replies

Localization :: Arabic Font Is Getting Corrupted Format?

Feb 6, 2010

i am getting arabic words like as follows in my system (server 2003) "ÎÕÈ ÈÎÇ" .

same words getting correctly in another machine.

artro.ttf and artrbdo.ttf files i nstalled in font folder.

View 1 Replies

Httpresponse - Why Are .docx Files Being Corrupted When Downloading From A Webpage

Mar 19, 2010

I have this following code for bringing page attachments to the user:

[code]...

The problem is that all supported files works properly (jpg, gif, png, pdf, doc, etc), but .docx files, when downloaded, are corrupted and they need to be fixed by Office in order to be opened.

At first I didn't know if the problem was at uncompressing the zip file that contained the .docx, so instead of putting the output file only in the response, I saved it first, and the file opened successfully, so I know the problem should be at response writing.

View 3 Replies

DataSource Controls :: Cyrillic Text Is Corrupted In PDF Report?

Apr 26, 2010

why cyrillic text is getting corrupted in PDF report.

I have set Arial UNicode Ms font in report. The column from where the data is retrived is also nvarchar(max).

So why the cyrillic text is getting corrupted.

View 1 Replies

Web Forms :: PDF Loading "file Damaged Or Corrupted With Message Box"

Nov 25, 2010

In my asp.net application. I am making one pdf template then bind the data with that template then save it on one folder. then pop the pdf file from that saved directory. Now all are fine. The problem is when i host the application sometimes i am getting message as the file is damaged or corrupted with message box. But when i get this error the i am going to refresh the page i will get the pdf file with data. Why It is not coming very first time. Why it is getting when we click on the refresh of browser.

View 2 Replies

Web Forms :: Calling Page In Div - The State Information Is Invalid For This Page And Might Be Corrupted

Aug 5, 2013

I am using Jquery Load and calling a page in a div.

Now while doing postback m getting this error The state information is invalid for this page and might be corrupted.

SO what might be the possible solution for the same.or is this error due to some other thing.

All this error am getting while doing postback.and when i refresh the page and do the same thing again it works absolutely fine.

View 1 Replies

State Information Is Invalid For This Page And Might Be Corrupted In Internet Explorer

Sep 28, 2010

I have used jquery for mbscrollable it working fine but when i run application in Internet Explorer it gives error on button which redirects to next page. Error is: The state information is invalid for this page and might be corrupted. Server Error in '/maxnetecommerce' Application. The state information is invalid for this page and might be corrupted. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The state information is invalid for this page and might be corrupted.

Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:

[FormatException: Invalid character in a Base-64 string.]
System.Convert.FromBase64String(String s) +0
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +102
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +59
System.Web.UI.HiddenFieldPageStatePersister.Load() +124
[ViewStateException: Invalid viewstate.
Client IP: 182.72.17.210
Port: 54486
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.1; .NET4.0C)
ViewState: /wEPDwULLTEwMjY3ODM1MjEPFgIeB2VuZERhdGUFAjMwFgJmD2QWAgIDD2QWBgIFD2QWAmYPFgIeBFRleHQF+CE8ZGl2IGlkPSdtZW51Jz48dWwgY2xhc3M9J21lbnUnPjxsaSBpZD0nMCcgb25DbGljaz0nc2V0Q29va2llKDApJz48YSBocmVmPSdEZWZhdWx0LmFzcHgnIGNsYXNzPSdwYXJlbnQnPjxzcGFuPkhvbWU8L3NwYW4+PC9hPjwvbGk+PGxpIGlkPScxJyBvbkNsaWNrPSdzZXRDb29raWUoMSknPjxhIGhyZWY9J1JlZ2lzdGVyLmFzcHgnIGNsYXNzPSdwYXJlbnQnPjxzcGFuPlJlZ2lzdGVyPC9zcGFuPjwvYT48L2xpPjxsaSAgaWQ9JzInIG9uQ2xpY2s9J3NldENvb2tpZSgyKSc+PGEgaHJlZj0nTG9naW5QYWdlLmFzcHgnIGNsYXNzPSdwYXJlbnQnPjxzcGFuPkxvZ2luPC9zcGFuPjwvYT48L2xpPjxsaSBpZD0zIG9uQ2xpY2s9J3NldENvb2tpZSgzKScgPjxhIGhyZWY9JyMnIGNsYXNzPSdwYXJlbnQnPjxzcGFuPkJpa2VzPC9zcGFuPjwvYT48ZGl2Pjx1bD4gPGxpIGlkPTMgb25DbGljaz0nc2V0Q29va2llKDMpJyA+PGEgaHJlZj0nQ2F0ZWdvcnlGZWF0dXJlZFByb2R1Y3RzLmFzcHg/UGFyZW50Q2F0aWQ9MzUmU3ViQ2...]
[HttpException (0x80004005): The state information is invalid for this page and might be corrupted.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +148
System.Web.UI.HiddenFieldPageStatePersister.Load() +10956310
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +11040040
System.Web.UI.Page.LoadAllState() +46
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11035559
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11035098
System.Web.UI.Page.ProcessRequest() +91
System.Web.UI.Page.ProcessRequest(HttpContext context) +240
ASP.default_aspx.ProcessRequest(HttpContext context) +52
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

But it works fine in Mozilla Firefox, when i remove mbscrollable from page no error comes

View 1 Replies

Internet Explorer - The State Information Is Invalid For This Page And Might Be Corrupted

Jun 22, 2010

I am receiving the following error when browsing my asp.net page in internet explorer while in firefox mozilla everything works fine. I have tried different approaches as I believe there is a problem with VIEWSTATE as to

- <pages enableViewStateMac="false" >
- <pages enableViewState="false">
- <pages viewStateEncryptionMode="Never">
- <pages maxPageStateFieldLength="40">

but nothing seems to work. The error looks like below: Source Error: [No relevant source lines]

Source File: c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Filesemportalermal7c94fef4cccf3353App_Web_mtkk1qfn.6.cs Line: 0

Stack Trace:

[FormatException: Invalid character in a Base-64 string.]
System.Convert.FromBase64String(String s) +0
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +72
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +113
[ViewStateException: Invalid viewstate.
Client IP: 127.0.0.1
Port:
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
ViewState: /wEPDwUKLTk3MzIyNTg5OA9kFgJmD2QWBAIBD2QWAgIJDxYCHgRocmVmBSV+L3Byb19kcm9wbGluZV8xL3Byb19kcm9wbGluZV9pbmQuY3NzZAIDD2QWBgIDD2QWAmYPZBYGAgkPFgIeBWNsYXNzBQZhY3RpdmVkAgsPFgIfAQUGYWN0aXZlZAJBDxYCHwAFFi4uL2FsL2NvbnRhY3RQYWdlLmFzcHhkAgUPZBYKAgEPZBYYAgEPDxYCHghJbWFnZVVybAUnLi4vaW1hZ2VzL0NhdGVnb3J5SW1hZ2VzL3BhcmFwYWd1YXIuZ2lmZGQCAw8PFgQeBFRleHQFCFN0YW5kYXJkHgtOYXZpZ2F0ZVVybAUULi4vYWwvcGFnZS5hc3B4P2lkPTRkZAIFDw8WAh4HVmlzaWJsZWhkZAIHDw8WCB4IQ3NzQ2xhc3MFDmNsaWNrZWRTdWJNZW51HwMFDlN1cGVyIFJpbmlyaW5nHwQFFi4uL2FsL3BhZ2UuYXNweD9pZD05MDgeBF8hU0ICAmRkAgkPDxYCHwVoZGQCCw8PFgIfBWhkZAINDw8WAh8CBSguLi9pbWFnZXMvQ2F0ZWdvcnlJbWFnZXMvbWUga29udHJhdGUuZ2lmZGQCDw8PFgQfAwUETGlmZR8EBRUuLi9hbC9wYWdlLmFzcHg/aWQ9NTBkZAIRDw8WBB8DBQZMaWZlICsfBAUVLi4vYWwvcGFnZS5hc3B4P2lkPTk2ZGQCEw8PFgQfAwUHTGlmZSA2MB...]
[HttpException (0x80004005): The state information is invalid for this page and might be corrupted.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +106
System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner, String persistedState) +14
System.Web.UI.HiddenFieldPageStatePersister.Load() +217
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +105
System.Web.UI.Page.LoadAllState() +43
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequest() +80
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.al_page_aspx.ProcessRequest(HttpContext context) in c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Filesemportalermal7c94fef4cccf3353App_Web_mtkk1qfn.6.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Remember that the error appear just in internet explorer

View 1 Replies

MVC :: Runtime Error In View Editor Corrupted Registry Entry?

Oct 25, 2010

One day I was developing my MVC app in Visual Studio 2010 and my computer crashed (flaky hardware - now fixed).But ever since then,in my app,whenever I have a view page or control editor up, the <%@ Page ... %> statement was squigley-underlined in blue with an tool-tip error message like:

/.../page.aspx: ASP.NET runtime error: Could not load file or assembly 'StructureMap, Version=2.6.1.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxx' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT:0x80070057 E_INVALIDARG))

I deleted and re-added the reference to StructureMap in the References in the solution explorer,deleted and re-copied the actual StructureMap DLL, but the error doesn't go-away.I deleted the output directories and rebuilt,but still have the problem.

The application still builds and runs okay, but while in the editor, though I continue to have IntelliSense for the HTML stuff,for any C# code inside <% %>'s, the IntelliSense is gone.

If I copy the application tree to another disk or directory,or rename the root directory to a different name,the problem goes away.But if I use the same name or disk,the problem appears.Maybe it's some corrupted registry entry?

View 3 Replies

Web Forms :: Show Progress Bar While Uploading Data In Database

Oct 16, 2013

I want to show progress bar while uploading data in database.. How can it be achieved. Also a message be displayed if file uploaded or not...

View 1 Replies

Forms Data Controls :: Image Uploading To Database - Get Error On Running

Jun 23, 2010

I am uploading images to database....but only error that I am getting at this point when I run it is for.....

DataSource.InsertParameters.Add("MIMEType", MIMEType)

The error for the above line is Object not set to an instance of an Object look over the code an see if you can see what is wrong.

Protected Sub Button_Insert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_Insert.Click
'Make Sure a file has been successfully Uploaded
If FileUpload_Image1.PostedFile Is Nothing OrElse String.IsNullOrEmpty(FileUpload_Image1.PostedFile.FileName) OrElse FileUpload_Image1.PostedFile.InputStream Is Nothing Then
Label_ErrorMessage.Text = "Error"
Else
Label_ErrorMessage.Text = "No Error"
'Exit Sub
End If
'Make sure we are dealing with a JPG or GIF file
Dim extension As String = Path.GetExtension(FileUpload_Image1.PostedFile.FileName).ToLower()
Dim MIMEType As String = Nothing
Select Case extension
Case ".gif"
MIMEType = "Image/gif"
Case ".jpeg", ".jpe"
MIMEType = "Image/jpeg"
Case ".png"
MIMEType = "Image/png"
Case Else
Label_ErrorMessage.Text = "Invalid Type"
'Exit Sub
End Select
Dim DataSource As New SqlDataSource()
DataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ToString
DataSource.InsertCommandType = SqlDataSourceCommandType.Text
DataSource.InsertCommand = "Insert Into ClassifiedImages (Title, DateUploaded, MIMEType, ClassifiedId) Values (@Title, @DateUploaded, @MIMEType, @ClassifiedId)"
DataSource.InsertParameters.Add("Title", "Images For Classified Ad" & " " & Request.QueryString("ClassifiedId"))
DataSource.InsertParameters.Add("DateUploaded", DateTime.Now)
DataSource.InsertParameters.Add("MIMEType", MIMEType)
DataSource.InsertParameters.Add("ClassifiedId", Request.QueryString("ClassifiedId"))
Dim ImageBytes(FileUpload_Image1.PostedFile.InputStream.Length) As Byte
FileUpload_Image1.PostedFile.InputStream.Read(ImageBytes, 0, ImageBytes.Length)
DataSource.InsertParameters.Add("ImageData", ImageBytes.ToString)
Dim RowsAffected As Integer = 0
Try
RowsAffected = DataSource.Insert()
Catch ex As Exception
Response.Redirect("AddImagesProblem.aspx")
End Try
If RowsAffected <> 1 Then
Response.Redirect("AddImagesProblem.aspx")
Else
Response.Redirect("AddImagesSuccess.aspx")
End If
End Sub

View 4 Replies

Forms Data Controls :: What's Best Method Of Uploading Multiple / Batch Images / Photos

Oct 30, 2010

I would like to know what the best method of uploading a batch of images/photos would be. Below are the steps that need to be implemented: Select Multiple images/photos from a directoryUpload original images to webserverGenerate thumbnailsUpload thumbnails to webserverAdd image and thumbnail details to a Database Does anyone know any vb.net script that will allow me to do this or will I have to code it from sratch?

View 2 Replies

Data Controls :: Update Existing Table Data By Uploading Excel File

Jan 24, 2016

Currently I was done to insert data thru upload excel file. May I know, how to UPDATE the existing data using iploading excel file.

View 1 Replies

C# - Uploading Data With HttpWebRequest?

Nov 17, 2010

I wrote following code to update data to website. Code run; but I am not able to see my data if uploaded. Here we have facility to see what data is getting uploaded but I am not able to see my data.

// Above URL is not real as I do not want to disclose real URL as of Now
Uri targetUrl = new Uri("http://www.x86map.com/post-embed/ewspost");
HttpWebRequest request = null;
StringBuilder sb = new StringBuilder();

[Code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved