0

I use input file=”type” and I want to priview the image and then to use this image details in server side..

This is priview the image but I can’t use it in server side, to put in db:

<input type="file" name="image_file" id="image_file" onchange="fileSelected();"/>

And if I do:

<input type="file" name="image_file" id="image_file" onchange="fileSelected();" runat="server"/>

So I don’t get a preview image.

I try to copy image_file value to new input type=”text” image_file2 like this:

<input type="file" name="image_file" id="image_file" onchange="fileSelected();"/>
<input type="file" name="image_file2" id="image_file2" runat="server" onchange="document.getElementById('image_file') = this;"/>

But it’s not working...

What can I do?

Patrick Hofman
  • 143,714
  • 19
  • 222
  • 294
  • 1
    I've formatted your code for you. Make sure you use the code format functionality when asking question so people can read your code (check the preview before posting the question!) Also, you need to describe "not working" as that can mean just about anything. – mason May 26 '14 at 14:32
  • What are you trying to achieve with your code? – Patrick Hofman May 26 '14 at 14:33
  • What is the code for `fileSelected` ? – Royi Namir May 26 '14 at 14:35
  • How do you setup the preview? I suspect `runat="server"` breaks everything simply because the ID is changing – Andrei May 26 '14 at 14:41
  • I create a web site, And one of the pages has an option to upload picture to website. I want the user to be able to see a preview (and more picture details) of the image before he click upload, so there is a function fileSelected() does this. But when I add runat = "server" to image_file - it does preview. – user3676706 May 26 '14 at 15:10
  • One option would be to upload it, let them see it, and if they don't click save, delete it from the server. – Andrew May 26 '14 at 16:15

1 Answers1

0

If I understand correctly

http://blueimp.github.io/JavaScript-Load-Image/

or

https://stackoverflow.com/a/4459419/995762

Community
  • 1
  • 1
marathonman
  • 452
  • 4
  • 9