473,758 Members | 5,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image upload problem

Hello,

I have a problem with uploading off images to my webservice, i convert
them to a byte[] at client side but something goes wrong when i try to
convert them back to a image at server side.
The webservice code:
[WebMethod]
public bool PutImage(byte[] ImgIn)
{
System.IO.Memor yStream ms =
new System.IO.Memor yStream(ImgIn);
System.Drawing. Bitmap b =
(System.Drawing .Bitmap)Image.F romStream(ms);

b.Save("test.pn g",
System.Drawing. Imaging.ImageFo rmat.Png);

return true;
}
and the code at client side:
private void button1_Click(o bject sender, EventArgs e)
{
string dir = System.Environm ent.CurrentDire ctory;
localhost.Servi ce t2 = new localhost.Servi ce();
if (openFileDialog 1.ShowDialog() == DialogResult.OK )
{
System.Environm ent.CurrentDire ctory = dir;
string ImageFilename = openFileDialog1 .FileName;
Bitmap bmpt = new Bitmap(openFile Dialog1.FileNam e);
Bitmap bmp = new Bitmap(bmpt);
// Create stream....
MemoryStream ms = new MemoryStream();

// save the image to the stream
bmp.Save(ms, ImageFormat.Bmp );
t2.PutImage(ms. GetBuffer());
}
}
the error i get is in the save function of the webservice: A generic
error occurred in GDI+.
at System.Drawing. Image.Save(Stri ng filename, ImageCodecInfo
encoder, EncoderParamete rs encoderParams). My code is almost the same
as this: http://www.codeproject.com/soap/ImageUploadWS.asp so it
should work but i don't see what could cause the error. I did put the
right permissions ;).

Apr 25 '07 #1
2 3658


"ge**********@g mail.com" wrote:
Hello,

I have a problem with uploading off images to my webservice, i convert
them to a byte[] at client side but something goes wrong when i try to
convert them back to a image at server side.
The webservice code:
[WebMethod]
public bool PutImage(byte[] ImgIn)
{
System.IO.Memor yStream ms =
new System.IO.Memor yStream(ImgIn);
System.Drawing. Bitmap b =
(System.Drawing .Bitmap)Image.F romStream(ms);

b.Save("test.pn g",
System.Drawing. Imaging.ImageFo rmat.Png);

return true;
}
and the code at client side:
private void button1_Click(o bject sender, EventArgs e)
{
string dir = System.Environm ent.CurrentDire ctory;
localhost.Servi ce t2 = new localhost.Servi ce();
if (openFileDialog 1.ShowDialog() == DialogResult.OK )
{
System.Environm ent.CurrentDire ctory = dir;
string ImageFilename = openFileDialog1 .FileName;
Bitmap bmpt = new Bitmap(openFile Dialog1.FileNam e);
Bitmap bmp = new Bitmap(bmpt);
// Create stream....
MemoryStream ms = new MemoryStream();

// save the image to the stream
bmp.Save(ms, ImageFormat.Bmp );
t2.PutImage(ms. GetBuffer());
}
}
the error i get is in the save function of the webservice: A generic
error occurred in GDI+.
at System.Drawing. Image.Save(Stri ng filename, ImageCodecInfo
encoder, EncoderParamete rs encoderParams). My code is almost the same
as this: http://www.codeproject.com/soap/ImageUploadWS.asp so it
should work but i don't see what could cause the error. I did put the
right permissions ;).

May 12 '07 #2
I found this website, which I have found works great!

http://blogs.msdn.com/agilemonkey/ar...-with-axd.aspx

I hope this helps
deDogs
"ge**********@g mail.com" wrote:
Hello,

I have a problem with uploading off images to my webservice, i convert
them to a byte[] at client side but something goes wrong when i try to
convert them back to a image at server side.
The webservice code:
[WebMethod]
public bool PutImage(byte[] ImgIn)
{
System.IO.Memor yStream ms =
new System.IO.Memor yStream(ImgIn);
System.Drawing. Bitmap b =
(System.Drawing .Bitmap)Image.F romStream(ms);

b.Save("test.pn g",
System.Drawing. Imaging.ImageFo rmat.Png);

return true;
}
and the code at client side:
private void button1_Click(o bject sender, EventArgs e)
{
string dir = System.Environm ent.CurrentDire ctory;
localhost.Servi ce t2 = new localhost.Servi ce();
if (openFileDialog 1.ShowDialog() == DialogResult.OK )
{
System.Environm ent.CurrentDire ctory = dir;
string ImageFilename = openFileDialog1 .FileName;
Bitmap bmpt = new Bitmap(openFile Dialog1.FileNam e);
Bitmap bmp = new Bitmap(bmpt);
// Create stream....
MemoryStream ms = new MemoryStream();

// save the image to the stream
bmp.Save(ms, ImageFormat.Bmp );
t2.PutImage(ms. GetBuffer());
}
}
the error i get is in the save function of the webservice: A generic
error occurred in GDI+.
at System.Drawing. Image.Save(Stri ng filename, ImageCodecInfo
encoder, EncoderParamete rs encoderParams). My code is almost the same
as this: http://www.codeproject.com/soap/ImageUploadWS.asp so it
should work but i don't see what could cause the error. I did put the
right permissions ;).

May 12 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
12018
by: lawrence | last post by:
I've been using the following function (yes, it is inelegant, what can I say, I wrote it a long time ago) to upload images. Haven't had a problem with it for at least a year, and I don't recall changing it anytime recently. Nevertheless, the script is suddenly dying on this line: if (copy($uploadedFile, $pathToImageFolder)){ This is the error I get:
3
11763
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
0
2382
by: Paul Hamlington | last post by:
Hello, I've been programming in ASP for a little while now and quite an advanced user, but I have come across an unusual problem in which I need assistance. I have built my own image upload, I have two versions of the binary to string conversion one fast, one slow because some servers use chillisoft and therefore the append function in not accessible for a disconnected recordset.
2
2881
by: Gary \(Girish\) | last post by:
Hello: I am using SA-FileUp to enable members to upload their product images to my ISP sever. When member uploaded a new image file, the file name is replaced with the member ID and the old file is then overwrited. Here is the problem: Member can uploaded new image at "Upload page" BEFORE viewing the new image at the "Detail page" without any problem. However, when member 1st viewed the image at the "Detail page" and then upload the...
15
5363
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
2
5957
by: prakharv | last post by:
Hi All, Below is the code which I am using to upload a jpeg file to the server. But the problem I am facing is that it is not copying the entire contents of the image file to the webserver and it doesn't works on IE. Please, help me out as I am new to this and would be highly thankful if anyone has running code for uploading image files to the server using CGI either Perl or C. This code i took it from net only. #!/usr/bin/perl -w
4
1794
by: Muddasir | last post by:
Hi.. i am having a strange problem.......the problem is i am trying to upload a file and to store it in db....when the file got stored in db...it got converted into black and white image and the stored in db with the same name("b"appended in the begining of the filename). now the problem is that...the following script only converts three images which i was using through out the testing phase......now it uploads only those three images...
10
7071
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for only small sized iamages.. for eg. resizing takes place for 70 kb sized images but fails for 600kb or more.. my code is below..
1
2036
by: sravani1 | last post by:
This code runs like when i submit the form it takes the image and displayed and top of the image a map will displayed. But actually i want that when i give the image it checks the location in the map and after displayed it.plz tell that how to start the logic. <?php // Connect to database $errmsg = "";if (! @mysql_connect("localhost","root","sreeni")) { $errmsg = "Cannot connect to database"; } @mysql_select_db("my_db1");...
1
4884
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop program,which can upload many file in folder.problem is,am unable to save my file name in to database.because i used same name for all input file type as file. i dont know get name of file.below i presented my coding for ur view.fed up with my coding..pls...
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.