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'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
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!
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 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
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 have a requirement where image has to be uploaded to a folder and show it in image control. When uploading the image i have resized the image through code and saved it in a folder. The code is as follow
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?
Is there any controls that I can download that allows a user to upload images with just a button click and be able to open the file dialog. I do not want to use the fileupload control.
This is the first time I've come across this kind of problem before and I'm having trouble approaching it.
I have a swf developed by someone else that posts an image and I have to create a handler of some kind to capture it, name it, then upload it to a directory. I've tried a couple ways and nothing is working.
this is a quick an dirty approach, just an aspx file
<%@ Page Language="C#" %> <%@ Import Namespace="Components" %> <%@ Import Namespace="System.IO" %> <script runat="server"> public partial class upload : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string uploadDirectory; uploadDirectory = Server.MapPath(@"images/"); string imageName = "image.jpg"; string uploadPath = uploadDirectory + imageName; //FileUpload imageUpload = new FileUpload(); // Get the data from the POST array string Email = Request["email"]; HttpPostedFile imageFile = _context.Request.Files["image"]; imageFile.SaveAs(uploadPath); } } </script>
this is another approach using a handler.
<%@ WebHandler Language="C#" %> using System.IO; using System.Web; using System.Web.Configuration; using System.Web.IHttpHandler; public class Uploader : IHttpHandler.i { public void ProcessRequest( HttpContext _context ) { string uploadDirectory; uploadDirectory = Path.Combine(_context.Request.PhysicalApplicationPath, @"images"); //uploadDirectory = Server.MapPath(@"images/"); string imageName = "image.jpg"; string uploadPath = uploadDirectory + imageName; //FileUpload imageUpload = new FileUpload(); // Get the data from the POST array string Email = _context.Request["email"]; HttpPostedFile imageFile = _context.Request.Files["image"]; imageFile.SaveAs(uploadPath); } }
I am looking for a solution (APIs, etc.) for handling a similar experience as cafepress.com. I need to be able to upload images (preferably multiple at a time) and be able to map my uploaded images to various product images (clean stock images of shirts, mugs, etc.). I also want to give the user some very basic controls over the images they upload such as cropping, resizing, levels, etc. I am looking for .NET solutions (if server-side).
I want that suppose user upload 2 MB image then from that image i want to generate 1 thumbnail image.To reduce its size , so i can get speed in loading. as my listing page contains many images.so i am getting to much loading time. SO can you tell me how can i compress image or get Thumbnail image?
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 have been messing around with uploading working with and then saving a resulting image.
However at the moment im getting errors in the outputted image, even with very simple code which takes the filebase, puts it into an image object then saves it back out.
Also i would like to know if there is a method in MVC to check the file extension or somehow determine wether it is an image file.
I am using a sql server 2008 database and I am uploading images to the server using an asp.net webapplication. I have an image column that I use to store the images. I have chosen the database to store the image and not a folder on the server, because the database table will contain only very few rows. maybe close to 10 or 15 rows.
My question is, Do I have to reduce the size (dimensions and quality affecting size on disc in kbs) of the image in code behind before uploading it to the database or do I keep it as is. The total upload size permitted is 200kb. I am thinking that when the image size (size in kbs) is small my webapplication performance will not be affected when displaying them from the database.
I have set up a simple bit of code to upload an image to the web server. It works offline without a hitch but online I get an error saying denied access.I am not overly surprised to be honest as I have not configured anything on the server (through my web host "Mochahost") to allow unknown users to upload files. I wonder if someone could point me in the right direction.