File Upload control, file loads in VS2008 and server browser, file fails load from client browser across LAN

Win2008 Standard with IIS7.0.

VS2008 website project with grid and upload control in form template.  File upload control loads image file to database blob column for display by grid.

Using Windows authentication for an intranet application.

Image file uploads to the database blob without errors in VS2008 test environment and from the Win2008 server IE7 browser.

Image file does not upload (falls through to CATCH for file not loaded) when file is selected from client IE7browser on LAN or WAN.

I suspect the problem is then with security setup of IIS 7.0 and/or web.config.

Unable to find specifics of requirements to upload files other than the fileupload control documentation.

Appreciate any insight.  Thanks


11/18/2008 9:00:42 PM 27051 articles. 1 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 55
Get it on Google Play
Get it on Apple App Store

I used this concept to solve.

Load image file to byte array and check for file size, file content, etc. as needed to verify it is an image file.

Convert byte array to bitmap

Convert bitmap to thumbnail, use any logic you need for this resizing.

Convert bitmap to memory stream and load into session variable (thumbnail might be 13KB or so in size)

Upload session variable into the BLOB column of the database. 

Private Sub ManageImageFile(ByVal currentUpload As FileUpload)

Dim FileLength As Integer = CInt(currentUpload.PostedFile.InputStream.Length)

Dim FileExtension As String = System.IO.Path.GetExtension(currentUpload.PostedFile.FileName).ToLower()

Dim FileContentType As String = currentUpload.PostedFile.ContentType.ToLower

If FileLength = 0 Then

ClientScript.RegisterStartupScript(Me.GetType(), "ClientScript", "alert ('File has no data. File not uploaded');", True)


ElseIf FileLength > 7168000 Then

ClientScript.RegisterStartupScript(Me.GetType(), "ClientScript", "alert ('File is greater than maximum allowed size of 7 megabytes. File not uploaded.');", True)


End If

Select Case FileContentType

Case "image/pjpeg", "image/jpeg", "image/gif", "image/png"

Case Else

ClientScript.RegisterStartupScript(Me.GetType(), "ClientScript", "alert ('Image formats limited to JPG, GIF, and PNG. File not uploaded.');", True)


End Select

Select Case FileExtension

Case ".jpg", ".gif", ".png"

Case Else

ClientScript.RegisterStartupScript(Me.GetType(), "ClientScript", "alert ('Image formats limited to JPG, GIF, and PNG. File not uploaded.');", True)


End Select

Dim ByteData As Byte() = New Byte(FileLength - 1) {}

Dim MemStream As New MemoryStream()

Dim bitmapWidth As Integer

Dim bitmapHeight As Integer

Dim thumbHeight As Integer

Dim thumbWidth As Integer


currentUpload.PostedFile.InputStream.Read(ByteData, 0, FileLength)

Dim tc As ComponentModel.TypeConverter = ComponentModel.TypeDescriptor.GetConverter(GetType(Bitmap))Dim bitmap As Bitmap = DirectCast(tc.ConvertFrom(ByteData), Bitmap)

bitmapWidth = bitmap.Width

bitmapHeight = bitmap.Height

If bitmapWidth < 100 AndAlso bitmapHeight < 100 Then

thumbWidth = bitmapWidth

thumbHeight = bitmapHeight


thumbWidth = 100

thumbHeight = ((bitmapHeight * 100) / bitmapWidth)

If thumbHeight > 100 Then

thumbWidth = ((bitmapWidth * 100) / bitmapHeight)

thumbHeight = 100

End If

End If

bitmap = DirectCast(bitmap.GetThumbnailImage(thumbWidth, thumbHeight, Nothing, New IntPtr), Bitmap)

bitmap.Save(MemStream, ImageFormat.Jpeg)

Session("DataVB") = MemStream.GetBuffer()




ClientScript.RegisterStartupScript(Me.GetType(), "ClientScript", "alert ('Failed to read file. File not uploaded.');", True)


End Try

End Sub



11/19/2008 7:24:27 PM

Similar Artilces:

file uploader save file on server and in database and upload this file on client
hi,i have a file uploader control user can attach files (.rar, .zip, etc) and store file folder and path in database. and another user can click of attach link and can download that file. how can i do this please solve out this problem. you can find your problem solution in this link and you can store the file name in your database server. Mark as Answred If This Blog has Helped You.RegardsMitesh Darjihttp://www.indianic.com As always there are many ways and which ...

Customizing File Browser on click of File Upload controls
hi, I have a FileUpload control provided by VS2005 in my application.On click of the "Browse" button, I get a file browser window. In the window, there is a "Files of Type" option where options like "All Files", ".doc" etc is listed. But i want to customize it to have only ".pdf" option. All the other options should be removed. How do i do it? Please help... You cant implement this using the default 2.0 file upload control. maybe this feature is provided in third party upload control. read the below link to check the file extension before you upload and then u can take the de...

ICSharp Zip File from Database to Browser Client Currpted File in Zip File
 I'm having an issue with zipping a file in-code, and pushign the file up to the browser. The file is stored as binary in a SQL 2005 database. If I retrieve the file from the database and send up to the client without zipping, it works fine. I can save the file to my desktop and I can open it just fine. Now, If I use common code I've found on-line to zip the file then send it up to the browser, the file in the zip archive is corrupt. That is, the zip file creates without error, and I can extract the file. But if I try to open the file (in my example it's just a small .gif f...

How to load files from file server in TreeView?
Dear All, How to load files from file server in TreeView? Any idea? Thanks in advance.  Regards, Joanne     Hi,What you can do is use this System.IO.DirectoryInfo di = new System.IO.DirectoryInfo("Web Server Physical Path"); then you can use di.GetFiles() method to get the files within the folder and you can manually put it in a Tree View. Hope it will help you out. Thanks and best regards,Faraz Shah KhanMCP, MCAD.Net, MCSD.Net, MCTS-Win/Web, MCPD-WebBlog Hi Joanne, You could write the file path into the node's url. so you can load the file when y...

Load report failed when trying to load a .rpt file. Too many Group Headers in the source file?
Hi all!After a lot of testing and troubleshooting I've come to the conclusion that the .rpt file won't load ( CrystalReportDocument.Load(InputFile); ) because of too many Group Headers in its file. If there is more than 80 Group Headers in the .rpt file, the file won't load. 80 or less, it loads fine. Is there a solution to this or does it mean putting a constraint on the people writing the files to never exceed the magical group header limit?The details of the error:InnerException: System.Runtime.InteropServices.COMException (0x80000206): Error in File C:\DOCUME~1\maaubell\LOCALS~1\Temp\...

How to File Upload and Download file ( .doc/.pdf/.gif/.exl) from server web browser C#
How to File Upload and Download file ( .doc/.pdf/.gif/.exl) from server web browser Please help me Thanking you Saikat   Uploading: Try a Google search for upload file web server c#. Download: <a href="">Download Me</a> HTH,RyanRyan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question HiI want to download this logo.gif . It is possable to download. Download: <a href="">Download Me</a> and How to File Upload .doc/.pdf/.gif/.exl file we...

How to identify the original file type and restrict the file uploading while using file upload control
 Hi , I am uploading a file using FileUpload control in using wrote the code to upload only PDF files. the user can change the extension and change to PDF . I have to check is the file original PDF or not then i have to upload the PDF files only . How to do this ??  Hi, Check the file Mime type for "application/pdf" by looking at the:  FileUpload1.PostedFile.ContentType RegardsSmcoxonNo Gem is ever polished without some friction. Hi smcoxon , Thanks For Replying ,But i found that there is no use using PostedFil...

File upload failed with INPUT FILE Controls?
Hi Experts, I'm uploading  files of size more than 100 KB. When I'm using File.PostedFile.Save() method to save the file on the server. I'm getting the error Can not open closed file. Can anybody help me in this ,to solve the problem. I changed MaxRequest length in Config file also. but still getting same error. Error Details :   System.ObjectDisposedException: Cannot access a closed file. at System.IO.__Error.FileNotOpen() at System.IO.FileStream.Seek(Int64 offset, SeekOrigin origin) at System.Web.HttpRawUploadedContent.TempFile.GetBytes(Int32 offset, Int32 lengt...

How can I control the size of a file when the file is upload to the server?
Hello! I am wondering how I can control the size of a file that the client load up to the server? I am working in C#. Sincerely, Albert Hi Albert, By control do you mean restrict the size of the upload? One way to do this would be to override the maximum request length with an entry in web.config, for example, the following would set the maximum length to 8 MB. <httpRuntime maxRequestLength="8192" /> The default is 4MB. HTH,Scott

Upload all files in folder with file upload control
H i I'm trying to upload all files to a wesite that is in a specific local folder. My code workes fine when I run it locally but when I upload it it fails. I think it looks for the files to upload on the web server and thus cannot find it.  1 Dim files() As String 2 folderExists = System.IO.Directory.Exists(foldername) 3 If folderExists = False Then 4 Label1.Text = "Folder does not exist. Did you enter a folder name or just a file name ?" 5 Exit sub 6 End If 7 files = System.IO.Directory.GetFiles(foldername) 8 For...

File Upload control-Control file size
I am using a file upload tool. I believe the default permissible size for a file uploaded through this tool is around 4 mb. How do I change this limit? I don't want it to be changed for all upload controls on the page. I just want it to be changed for one particular control which uploads music. I want to raise the uploaded file size limit for music to 10MB. hi, here are some information for you to refer to,

Deleting A File Uploaded Through File Upload Control
Hello, I have a form which allows a user to upload a file to a virtual drive on our server using the following code: fileInvoice.SaveAs(ConfigurationManager.AppSettings.Get("DocumentPath") + strFileName); //Document Path is defined in the web.config file How can I safely allow a form on a web page to delete the file if they know the exact name of the file. I don't want them to be able to do a wildcard match like test* thanks in advance, mitch  Peace be on you brother, so you want to safely delete the file which the name you know. OK I consider that the name ...

How Do I Enable A File Upload Control When Another File Upload Control Has A Value?
Hi There,Thanks you for taking the time to read this post.  I am quite new to programming and have searched the net and experimented with my own code but not been able to get it to work yet.I am creating a simple CMS for a friends site and my friend wants to be able to upload 9 images per page.I have created an form with 9 file upload controls.  I want 1 control to be enabled by default and the other 8 controls disabled until the previous control has a value.  I have set the default setting in visual studio without any problem.My first thought was to double cli...

Posting filepath in file upload control in .NET to the next page and uploading the file from second page
In our application (using C# .NET) there is a form with file upload options. After filling up the form details, the summary of the details need to be shown in the next page before committing the information into the database. Right now, Server.Control is used to transfer the contents to the next page and the form details are retrieved using Request.Form["control id"]. But this is not working for File upload control alone.File upload can not be done in the first page itself, as the foreign key in File upload table gets updated only in second page after confirmation. Therefore, is th...

Web resources about - File Upload control, file loads in VS2008 and server browser, file fails load from client browser across LAN -

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

TERROR IN JAKARTA: 'Situation under control' after explosions, gunfire erupt in Indonesian capital
At least six people are dead, including three police officers, after several explosions at the Sarinah shopping mall in an apparent multi-site ...

Backburn approved in bid to control bushfire before blaze hit Wye River - HeraldSun Search Search
A BACKBURN was approved to try to control a bushfire in the days before it tore through more than 100 homes in Wye River on Christmas Day.

DFES downgrades bushfire in Dunsborough as it is contained, but not under control
A BUSHFIRE south of Dunsborough has been contained but is not yet under control.

WA fires: threatening Jindalee blaze brought under control
A fire that was at one stage a threat to lives on homes in Jindalee on Thursday has been brought under control.

Queensland police shut down out-of-control party in Berserker, Rockhampton
Police shut down a party of 150 young people who had gathered at a house in Berserker, Rockhampton on Friday night.

BMW recalls i8 for stability control problem
... , BMW , Safety , Coupe , Hybrid , Performance BMW will recall a small number of 2015 i8s because of a problem with the dynamic stability control ...

ESI cost control and networks
There is an interesting discussion thread on Twitter about how the way Medicare for All saves money is by significantly reducing provider, device, ...

Apple has landed a very rare sponsorship deal to ensure it has control of the hottest ticket in San Francisco ...
Apple has signed up for the first time to become a sponsor of the Super Bowl Host Committee, Daniel Roberts at Yahoo Finance reported. It's ...

Leonardo DiCaprio: The Oscar stuff is ‘completely beyond my control at this point’
... last night’s London premiere of The Revenant . Leo is looking pretty good these days. He’s de-bloated, his facial hair is very much under control, ...

Resources last updated: 1/16/2016 6:28:50 PM