|
 |
|
|
 |
|
|
thanks for the wonderful code, i loaded and ran it on visual studio .net 2003, i'm able to upload the jpegs but after that it doesnt display, any idea what's wrong?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
// If file field isn’t empty if (filUpload.PostedFile != null) { // Check file size (mustn’t be 0) HttpPostedFile myFile = filUpload.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen == 0) { lblOutput.Text = "There wasn't any file uploaded."; return; }
// Read file into a data stream byte[] myData = new Byte[nFileLen]; myFile.InputStream.Read(myData,0,nFileLen); Bitmap b = new Bitmap(new MemoryStream(myData));
}
you might consider adding a try and catch on the new bitmap block ..
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Its a fantastic example of uploading image files but i m unable to upload file with size greater than 100 kb when i deploy the application and access it through internet locally it works fine !
waiting for Reply ! Thankx in advance..
|
| Sign In·View Thread·PermaLink | 3.00/5 (3 votes) |
|
|
|
 |
|
|
 |
|
|
in your code you have
"if (filUpload.PostedFile != null)"
This is straight from MSDN library:
Before calling the SaveAs method to save the file to the server, use the HasFile property to verify that the FileUpload control contains a file. If the HasFile returns true, call the SaveAs method. If it returns false, display a message to the user indicating that the control does not contain a file. Do not check the PostedFile property to determine whether a file to upload exists, because this property contains 0 bytes by default. As a result, even when the FileUpload control is blank, the PostedFile property returns a non-null value.
I bolded the important part.
thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
hey i love the code
just wondering is there any way to keep the aspect ratio, by asy only declaring the height and leaving the width auto? just for when you insert portrate pictures for example
cheers
Jez
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Thanks for the Code it is very useful what should i do to show more then 1 thumbs on the display page...
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
|
Great article. It has helped tremendously. The only problem is that I cannot get the jpg to display when the page reloads. Any suggestions?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Thanks for the article.
I had to remove: protected System.Web.UI.HtmlControls.HtmlInputFile filUpload; protected System.Web.UI.WebControls.Image imgPicture; protected System.Web.UI.WebControls.Label lblOutput; protected System.Web.UI.WebControls.Button btnUpload;
In order for the code to compile. In fact I had to create a new solution, add a new file, copy your code to that file, remove the above reference and build. I first tried to get this to work in VS Web dev edition, with no luck. Then installed VS 2005 and finally success. I am not sure why the framework is so touchy.
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
|
 |
|
|
Hi Chris;
This worked like a charm, not a problem...
I have a question for you.
I want the user to select a file from thier HD, then upload just the resized image to the server.
Currently the demo Uploads the original as well as the resized image.
I tried removing the portion of the code that writes the original picture, but i get errors. so obviously i am removing the wrong portion.
Can you email me please?
Thank you
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
these are the important lines, you must to add the try catch sentences, but this code works
if (filUpload.PostedFile.FileName.Trim().Length > 0 && filUpload.PostedFile.ContentLength > 0) // No name, No empty { string baseRoot = "C:\\Inetpub\\wwwroot\\mySite\\images\\"; string[] directories_name = filUpload.PostedFile.FileName.Split('\\'); string fileName = directories_name[directories_name.Length - 1]; //Get the file name include the extension string finalRoot = baseRoot + fileName; Foto.PostedFile.SaveAs(finalRoot); Mensaje.Text = "The image was uploaded onto: " + finalRoot; }
keep Learning...
|
| Sign In·View Thread·PermaLink | 1.67/5 (2 votes) |
|
|
|
 |
|
|
 |
|
|
Dear Sir, I use your code to Upload Image as standalone and it works fine. I have started facing problems while Trying to use the code in DataGrid. I set in Edit mode in Template Coloum the HTML File Control and I wanted to upload the Image to specific directory and the file name to store in Access DB. I couldn't catch the HTML Control in the UpDate Method (Working with C#..) and to continue the running of the code.. Pls Help. Thanks ArnLee
P.S. 1. The UpDate Method .. private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { File TmpabcPic1 = (File)e.Item.FindControl("abcPic"); ....continue the code...
2. the control in the ASPX Page..
<input type="file" id="abcPic" name="abcPic" runat="server" size="50" />
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
With the HTML File field, converted to a server control, simply
1: Verify that the file is an image ( btnFile.PostedFile.ContentType == "image/pjpeg") 2: Verify size constraints ( btnFile.PostedFile.ContentLength ) 3: Get the strings path, fileName as in the example, and
btnFile.PostedFile.SaveAs( path + fileName );
This does seem to take a little longer to upload than does the example, but I have experienced problems with the above, in that sometimes the file I uploaded didn't get recognized as a JPEG on the server, don't know why.
Phil
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
The easiest way to upload and resize an image to the internet is I-Load. I-Load is a FREE ASP.NET web control with numerous benefits and features. You can download I-Load (it's FREE!) and view an online demo here:
http://www.radactive.com/en/Products/ILoad/Overview.aspx
|
| Sign In·View Thread·PermaLink | 1.00/5 (5 votes) |
|
|
|
 |
|
|
Hi,
Thank you for posting your code. I found it very helpful. One problem I do encounter is the following: In debug mode, I have a breakpoint set at the beginning of the submit method. When I try to save a smaller file, it works just fine, but if I try to upload a file > 4 MB, the debugger doesn't even get to the first line of the submit method. Furthermore, I don't receive an ASP.NET error page, just a generic IE Error ("Could not locate file blah blah blah").
Does anyone have any thoughts about where in the ASP.NET page lifecycle the error is occurring? Is the message being sent to the server just too darn big?
Thanks in advance for your help,
virsum
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
there is a file size restriction in the web.config file, i don't remember what it is exactly but it has a default of 4 mb.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Add httpRuntime maxRequestLength="24576" to the system.web section.
24576 will allow 24 MB uploads, you can adjust this as needed.
Correct, the default is 4 MB.
Hope this helps.
Victor
-- modified at 13:19 Monday 24th April, 2006
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
i want to upload all files from selecting the folder or specify that folder path.
one by one file will be upload on web server path using .NET application as well as vb6 application.
sachin
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
|
I have the following error,,
would u please help me for it,
Access to the path "c:\inetpub\wwwroot\testimgupload\images\ppp.jpg" is denied
and it point to the following line:
Dim newFile As System.IO.FileStream = New System.IO.FileStream(Server.MapPath(sSavePath + sFilename), System.IO.FileMode.Create)
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Check the permissions on that folder, using windows explorer right click and select properties, then select security (for xp pro or sharing xp home) then check that iusr has write permissions on that folder.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |