how can i control, the width and hight of an image which a user select in an uoload control,for uploading, with specific size(width=150px,hieght=100px)
i want the user only select the image in that specific size of image.
I've been playing with the FileUpload control for an upcoming project where the user is allowed to upload up to five files at once, but each file can only be 5MB in size. Simple enough all I would need to do is add in the httpRuntime element to the web.config and up the file size and timeout.
[Code]....
what I'm really getting at is there a better way to trap if the file size is too large before processing while using the FileUpload control. I would like to be able to keep the user on the same page but update a label control.
I use file upload control. How I can define that user can upload 300kb if they upload more than 300kb it show error that they can't upload more than 300KB...
here i define if (fup1.PostedFile.ContentLength < 102400) this size for image but when i upload image that has more than this 100KB it show error ===File size of 756 KB is exceeding the uploading limit but it upload file i don't want users can upload file morethan 100KB but here show error but upload image why?
I do not want to change the default settings for file upload, 4Mb is more than enough for the project I'm working on. After quite a bit of searching I found two approaches that were purported to work but neither one is preventing the "Maximum request length exceeded" error. The first approach[see ref. #1 below] performs validation with a custom validator and in code behind on the page that contains the FileUpload control. It doesn't work. The second approach [see ref #2 below] performs validation in the Application_BeginRequest event in Global.asax. The author stated that validation must be handled by this event. Quoting: "The way to get past is to use your Application_BeginRequest event to handle the problem.. This event takes place for each request to your application BEFORE the data has been completely uploaded. Here you can check for the content length of the request and then redirect to the some error page or the same page with some value in session or query string so that the page can show appropriate message to the user." Here is my code from Golbal.asax based on the above. As noted, this approach doesn't work either.
protected void Application_BeginRequest(object sender, EventArgs e) { const int maxFileSize = 4 * 1000000; // Slightly less than 4Mb if (Request.ContentLength > maxFileSize) { Response.Redirect("~/FileUploadError.aspx"); } }
One comment by a reader of the Global.asax approach was that the value returned by Request.Content.Length would include everything on the page, i.e. viewstate, image and text content, etc. I suppose one work-around would be to set the limit higher in web.config but validate for max. file size in code behind, but that seems kind of silly because I'm manipulating the uploaded files (images) to reduce the size anyway; storage space isn't the issue, performance is. Has anyone managed to solve this poblem?
i am not able to show an alert message when a file is uploaded from a FileUpload control which is more than the size mentioned in web.config file like this in my situation...
Iam trying to upload around 10-12 different images and vedio using seperate separate FileUpload but when I pressed submit button it will show "This page cannot be displayed" and not execute the code.
I have a web app that allows users to upload images. Last week, all was well. This week, it appears the code is breaking. Here is the code:
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click If FileUploadControl.HasFile Then Dim month As String = ddlMonth5.SelectedValue Dim year As String = ddlYear7.SelectedValue ' Dim whatis As String = FileUploadControl.PostedFile.ContentType Try If (FileUploadControl.PostedFile.ContentType = "image/jpeg") Or (FileUploadControl.PostedFile.ContentType = "image/pjpeg") Or (FileUploadControl.PostedFile.ContentType = "image/gif") Or (FileUploadControl.PostedFile.ContentType = "image/x-png") Then Dim fs = New FileStream(FileUploadControl.PostedFile.FileName, FileMode.Open, FileAccess.Read) 'save file with new size Using image As System.Drawing.Image = System.Drawing.Image.FromStream(fs) Using bitmap As New Bitmap(image) bitmap.Save("C:WebsitesimagesCusRespData.jpg", image.RawFormat) bitmap.Save("C:Websitesimages" & month & year & "CusRespData.jpg", image.RawFormat) End Using End Using StatusLabel.Text = "Upload status: File uploaded!" fs.Close() fs = Nothing Else StatusLabel.Text = "Upload status: Only .jpg,.jpeg,.gif and .png files are accepted!" End If Catch ex As Exception StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " & ex.Message End Try StatusLabel.Visible = True End If End Sub
On the development side, I see this error: The file could not be uploaded. The following error occurred: Could not find a part of the path. On the production side, this occurs: The following error occured: A generic error occurred in GDI+.
I have problem of using fileupload control, I want to upload an image into database and at the same time I also want to add the image into images folder.I can insert the image into database but I can't insert it into images folder. I don't know where I wrote wrongly and below are my codes :
i want to create a slide show of user selected images, i want to give user an option where he can upload multiple images with single fileupload control,
How can I display photogarphs in an image control so that they are all the same size for an online catalogue without distorting the actual image.
I have taken the photos with a digital camera, loaded them in to Photoshop, cropped the image and finally resized the images to an acceptable size (while constraning proportions to avoid image distorsion).
The problem is that the images all have different height dimensions as while resizing i was able to choose the width that I wanted but as I had to constrain proportions to avoid distorsion, it caused the heights of the images to differ.
On my web form I have an image control that is set to the same width as the images but as the heights of the images differ from one and other, it is impossible for me to set a fixed height that will prevent some of the images being distorted when displayed in the image control.
i want to display the image either from a database or through file upload control but in case of database i had seen your article but what binary data i can store as you had in data column table and when i save a file somewhere through file upload but it is not displaying the image.
i am uploading a file through file upload control , file size has greater then 4 MB, I have to give the proper alert msg to the user that file size exceeding the limit.how to do it , because at server side it is crashed on the IIS and not return to the server to check the file size validation.that how it is possible to validate the file size and give the proper alert messege
and i convert it into pdf file. my data with logo converting pdf format properly.but logo image displayed in large space. how to compress it.my pdf button code is-
I want when user click on any of the images, it should take them to another page UploadedImage.aspx, displaying the clicked image in full size. Can someone help me accomplish that?
I'm going to design a database for an image gallery in ASP.NET Web App . Because of some reasons I've decided to store the image in Data Base , Not the address .
In the application i need two or more different size and weight image for each image that the admin insert .For instance , One of them is small and lightweight thumbnail , and the other is Original big one .
My question is : Should i have two column ( one for lightweight and small thumbnail and one for big and full size one ) in DataBase Or Is there any way i could load different size and wight image from Big and original image column ?