I'am Developing a commercial website using vs2005 and sql 2005,where my users will download and upload wallpapers and ringtones,so my issue is, i got the coding for uploading ,
But the problem is it is storing the files two times,
If FileUpload1.PostedFile IsNot Nothing Then
Dim FileName As String = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName)
FileUpload1.SaveAs(Server.MapPath("Images/" & FileName))
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
in my application i am uploading the image into database. before it is store in the database, i want to do image management like decreasing size and decreasing height and width of the image.
I am able to upload an image to a Database from a fileupload control on a detailsview inserting event and then display it again. Here is my code to upload an image from a fileupload control:
Dim UploadedFile2 As FileUpload = CType(DetailsView1.FindControl("Fileupload2"), FileUpload) Dim extension2 As String = Path.GetExtension(UploadedFile2.PostedFile.FileName).ToLower()
I have a problem about image control. I am using VS2005 in Vista and suddenly uploading and retrieving image to a image control doest not work. I am working with this in Windows XP and all goes fine. After transfering it to vista, I can't upload and retrieve an image stored in the File System. My codes are all the same.
I Used AsyncFileUpload(one of Ajac Control Toolkit Controls) to Uploading User's Image. this works well. But i want to change the image url of an image contorl to uploaded image url. how can i perform that? I put Image control in a Update Panel:
[Code]....
in C# code I wrote these:
[Code]....
But it does not work. Image is like Previous. Note that ImageOperations.ResizeFromStream() method resizes and saves the image to a specefic folder. actually I should trigger a Postback to Update the Update Panel but How to do that. I usedUpdatePanelNew.Update(); but it does not work!
look at the picture, i want that image preview will come when i choose the file location before uploading to the database. is it possible?
EDIT: i found codes in other sites, they say those only work in IE, so it means currently, this preview function doesnt support FF? coz im using FF or sometimes google chrome.
I'm trying to craete an upload form using the following code:
[Code]....
when I click the 'Add imag' button I keep getting this error:String or binary data would be truncated. The statement has been terminated.the 'Image' column in the SQL database is set to VARBINARY(250) and this exception still pops up even when I'm trying to upload a small 3kb JPG image, why is that?
Users of my C# web application can upload images. I have configured the max upload size in the web.config file to maxRequestLength="1024" and executionTimeout="180".
How can I check the upload size before uploading? (do you have examlpe or url?) Another option might be to check the dimensions?...
Some web application allow the user to crop the image at client side. Do you have an example of this or url?
I wish my user to have option of selecting multle image at once and upload them to site form there hard drive, somehing like on copy paste, and not to have 5 upload buttons and to look for each photo separatly.
I have thi esolved in zip file where user can zip in let say 453 photo and upload them to internet in single file where they are automaticli unziped but it would be much better to have option of selecting numerus photo i windows explorer and upload thm with single click
I am developing website in asp.net,I am hanging up in following problem:
I have 2 subdomains (say admin.D1.com & sms.D1.com).
For security purpose, I want to save and retrieve image files at particular folder(say Fldr1),above to both subdomains.(File should be saved and retrieved from both the subdomains)
[code].....
It gives follwing error:
"The SaveAs method is configured to require a rooted path, and the path [URL] is not rooted."
i am working on an ecommerce application, user will be uploading several images of a product, instead of stripping the size (i.e the KB or MB size) after uploading it on the server, i want to strip the size of image before uploading it to the server ( bringing the size from any thing over 30KB down to 30KB) i.e on the client machine itself and then upload it to the server. i understand that this requires a download on the client machine which makes me ask the following questions :
a. can i use a java control in dotnet since java control can be used on all OSes b. is there any dotnet control that might be userfriendly to all OSes
this is my code ...iam storing & retrieving image from db using gridview but now i got stuc..how to dispaly default imag ewhen user is not uploading the iamge..
this is insert image to db..
[Code]....
this is where iam retrievieng the iamge ...
[Code]....
this is where iam using gridview to dispaly images ...
I am using VB to upload image files to my server but am having problems. How can I use the ContentType to filter only image files? This is my code for my upload button which does not seem to be working. I can only upload bmp files:
[Code]....
Also, how can I show the user the image they uploade
I want to create a folder (titled their userid) for each user for Images they upload. I also want to name their files as their username + 1 or 2 or 3... whatever number of images they have.
Visual Studio 2008. I've done a page to upload images in asp.net web application.. . Now I need to create a web service which would be able to convert the image by our given height and width before uploading.........
i am using file upload control for uploading images. in that iam checking the condition,if Image.Width > 250 || Image.Height > 400 then i am resizing the image. but it is giving the error "The SaveAs method is configured to require a rooted path, and the path 'ProductImages/roman_sandals.jpg' is not rooted."
ProductImages is folder where i am saving image. Can anyone find why this is giving error,my code is
Got a problem with regards to the file upload control on database updates. The problem is in my CMS, when a user tries to update content for a page it will add null to the fields containing the image path. What I need is for the system to check if the uploader has no image and if hasn't it has to do nothing. It can't add empty strings or null values as this will remove the original image path. Although they still need to be able to do image updates if the uploader has a file(this bits not a problem).
Here is a snipet of code to demonstrate what I'm trying to achieve.