开发者

How to send an image from desktop(client) to server & vice versa

I have a web page, by clicking on a Button

  1. a file browser dialog box opens (it should be able to access the client's system)
  2. choose a jpg/gif/any image file and click OK to send
  3. send it to server via AJAX
  4. once the image saved in serve开发者_如何学Gor, a confirm message appears and
  5. save image populated on client machine in dialog/another window

No. 3, 4 can do using Ajax and server side programmimg (java), but i am not very confident about 1, 2 & 5.

Please help...

Thanks in advance


1 & 2 Use an HTML input tag of type file: <input type='file' id='uploadfile'>. Alternativly if you don't mind using a little flash Uploadify is pretty cool. I', not sure what you mean by step 5. Do you want the uploaded image to be displayed somewhere on the active browser window?


  1. A standard file input.
  2. Better validate filetype on the server not client. You may use accept attribute, but there's no use from it in most browsers.
  3. Use ajaxupload
  4. Send ajax response and handle it on the client side. Display the image in img, for example.
  5. Not sure. Why do you want to save it when the user just uploaded it from his machine?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜