Uploaded image into thumbnail
-
hi to all, I am using asp.net 2.0, in that I designed a webpage for uploading an image. If the user uploads an image it should be automatically change in to thumbnail and it is displayed in that website. I searched in Google but I didn’t get the proper coding for that. So, please help.
jai prakash
-
hi to all, I am using asp.net 2.0, in that I designed a webpage for uploading an image. If the user uploads an image it should be automatically change in to thumbnail and it is displayed in that website. I searched in Google but I didn’t get the proper coding for that. So, please help.
jai prakash
Why have you posted your question again? You only posted your original question 30mins ago. Don't you know that it is rude to do this? You won't necessarily get an immediate response to your question. This is a free site, so unless you are going to pay someone for advice you should be prepared to wait. I've answered your first post. Please read it and remember not to double-post in future.
Paul Marfleet
-
Why have you posted your question again? You only posted your original question 30mins ago. Don't you know that it is rude to do this? You won't necessarily get an immediate response to your question. This is a free site, so unless you are going to pay someone for advice you should be prepared to wait. I've answered your first post. Please read it and remember not to double-post in future.
Paul Marfleet
-
sorry ya,here after i will not do it. I cont get a clear idea from that link. Is there any other link for full code. Please help me.
jai
I gave you the link to the documentation that shows you how to use the
Image.GetThumbnailImage
method to create a thumbnail image. The other tasks - uploading an image, saving an image to the file system, displaying an image in a web page should be trivial. What is it that you don't understand? There will be plenty of examples on the web to implement these individual tasks if you search for them. You're not going to find a single article where you can cut-and-paste the code to immediately solve your problem. As a developer, you should be able to apply your problem-solving and research skills to find a solution. It's not going to be handed on a plate to you.Paul Marfleet
-
sorry ya,here after i will not do it. I cont get a clear idea from that link. Is there any other link for full code. Please help me.
jai
Hi, Jai, I have sending you the code from one of my application, please change it accordingly and let me know when done...... :) And it's only for jpg, and u cna do it for any one..... :) :) :) protected void Button2_Click(object sender, EventArgs e) { string sSavePath; string sThumbExtension; int intThumbWidth; int intThumbHeight; sSavePath = _Default.fullpath; sThumbExtension = "_thumb"; intThumbWidth = 160; intThumbHeight = 120; // If file field isn’t empty if (FileUpload1.PostedFile != null) { // Check file size (mustn’t be 0) HttpPostedFile myFile = FileUpload1.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen == 0) { lblOutput.Text = "No file was uploaded."; return; } // Check file extension (must be JPG) if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg") { lblOutput.Text = "The file must have an extension of JPG"; return; } // Read file into a data stream byte[] myData = new Byte[nFileLen]; myFile.InputStream.Read(myData, 0, nFileLen); // Make sure a duplicate file doesn’t exist. If it does, keep on appending an // incremental numeric until it is unique string sFilename = System.IO.Path.GetFileName(myFile.FileName); int file_append = 0; while (System.IO.File.Exists(( (sSavePath + sFilename)))) { file_append++; sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString() + ".jpg"; } // Save the stream to disk System.IO.FileStream newFile = new System.IO.FileStream((sSavePath + sFilename), System.IO.FileMode.Create); newFile.Write(myData, 0, myData.Length); newFile.Close(); // Check whether the file is really a JPEG by opening it System.Drawing.Image.GetThumbnailImageAbort myCallBack = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); Bitmap myBitmap; try { myBitmap = new Bitmap((sSavePath + sFilename)); // If jpg file is a jpeg, create a thumbnail filename that is unique. file_append = 0; string sThumbFile = System.IO.Path.GetFileNam
-
Hi, Jai, I have sending you the code from one of my application, please change it accordingly and let me know when done...... :) And it's only for jpg, and u cna do it for any one..... :) :) :) protected void Button2_Click(object sender, EventArgs e) { string sSavePath; string sThumbExtension; int intThumbWidth; int intThumbHeight; sSavePath = _Default.fullpath; sThumbExtension = "_thumb"; intThumbWidth = 160; intThumbHeight = 120; // If file field isn’t empty if (FileUpload1.PostedFile != null) { // Check file size (mustn’t be 0) HttpPostedFile myFile = FileUpload1.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen == 0) { lblOutput.Text = "No file was uploaded."; return; } // Check file extension (must be JPG) if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg") { lblOutput.Text = "The file must have an extension of JPG"; return; } // Read file into a data stream byte[] myData = new Byte[nFileLen]; myFile.InputStream.Read(myData, 0, nFileLen); // Make sure a duplicate file doesn’t exist. If it does, keep on appending an // incremental numeric until it is unique string sFilename = System.IO.Path.GetFileName(myFile.FileName); int file_append = 0; while (System.IO.File.Exists(( (sSavePath + sFilename)))) { file_append++; sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString() + ".jpg"; } // Save the stream to disk System.IO.FileStream newFile = new System.IO.FileStream((sSavePath + sFilename), System.IO.FileMode.Create); newFile.Write(myData, 0, myData.Length); newFile.Close(); // Check whether the file is really a JPEG by opening it System.Drawing.Image.GetThumbnailImageAbort myCallBack = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); Bitmap myBitmap; try { myBitmap = new Bitmap((sSavePath + sFilename)); // If jpg file is a jpeg, create a thumbnail filename that is unique. file_append = 0; string sThumbFile = System.IO.Path.GetFileNam
-
Html, Coding, is very big one becuase , Image uploading is a small part of the page, u can test it using Create a ImageBox, Take a fileupload control and 1 button put the code in Button_1 Click { } and in outsides.... ThumbnailCallback() Any query ask me !!!! :)
Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"
-
Html, Coding, is very big one becuase , Image uploading is a small part of the page, u can test it using Create a ImageBox, Take a fileupload control and 1 button put the code in Button_1 Click { } and in outsides.... ThumbnailCallback() Any query ask me !!!! :)
Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"
-
Hi jai,
jai aswitha wrote:
sThumbExtension = " ";
I have mention sThumbExtension ="_thumbs" u can give anything.... If you uplaod a file with abhijit.jpg then its thumbs should be abhijit_thumbs.jpg:cool: is it clear ??? or you want to ask some think different !!!!:confused:
Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"
-
Why have you posted your question again? You only posted your original question 30mins ago. Don't you know that it is rude to do this? You won't necessarily get an immediate response to your question. This is a free site, so unless you are going to pay someone for advice you should be prepared to wait. I've answered your first post. Please read it and remember not to double-post in future.
Paul Marfleet
-
Please check my reply to jai, for the same !!!
Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"