This is new to me since I did something similar a few years back:
<input type="file" onchange="fileSelected(this.value)" />
This will provide a fakepath ref开发者_JAVA百科erence, IE, if I select test.jpg
on my desktop it returns:
c:/fakepath/test.jpg
My problem is, I'm developing an online application that lets clients design a page, that is, they select images, drag them onto the page etc.
My design ideally would be they select local files (that could be big in filesize) so there is no uploading involved immediately, I keep an array of the paths of the files and then at the end of the design process it saves the media and the positions of elements to the server.
However, fakepath is preventing me from doing this!
Do I have to upload the files each time? This would significantly slow down the design process.
However, fakepath is preventing me from doing this!
This is a security feature (see related SO questions). Even if there were a real path, you would not be able to add the file path to the upload control programmatically later. AFAIK it's not even possible with Flash uploaders any more.
You will either have to use/build a Java Applet or ActiveX control (yuck!), or in fact actually upload each file.
精彩评论