Preview Image before uploading file

后端 未结 4 1603
南笙
南笙 2020-12-11 14:18

I have got one problem by uploading file. I created an aspx file in asp.net then I added a fileupload control and image control. I want to show preview image in image contro

4条回答
  •  孤城傲影
    2020-12-11 14:24

    You can't, for security reasons the full path of the file isn't made available to your script (if it were, you'd have to perform transformations on it to use it as a URL).

    On some modern browsers, you could use the new File API to actually read the image data and show it on the page. I've previously written another answer here on SO shows how to do that (in that case, so we can find the image dimensions).

    But other than that, you have to assume the user has a means of seeing what image they've chosen, aside from your web page.

提交回复
热议问题