开发者

File path for upload as PHP URL parameter

I am trying to pass a path to a local file to a PHP upload form. I have a basic upl开发者_运维知识库oad form with an <input type=file etc..> and I am trying to set this value using the parameter I passed in when calling the PHP script from my browser.

In searching around a good bit, I understand this is not possible for security reasons. Otherwise someone could automatically upload your files when you went to their site. Is it true that specifying the value for the <input type=file > is not possible? If so, are there any alternate ways of doing this or any workarounds?

Thanks


It is true that this is not possible. The way that <input> is handled is entirely up to the browser, and you have no control over it.

You could look into building a Flash uploader, but I doubt it's file browse capability is any different.


You can take a look at SWFUpload. It has a lot of good features like:

  • Restricting the type of files the user can select in the dialog
  • Multi-file uploading
  • Ajax-like file uploads

I am not, however, sure if it allows you to set the default directory. An initial look at the configuration options and the reference manual for the Flash.net.File class makes me think that it is not possible even with Flash. However, the file-type restriction might make life a little easier on your users.

Java Webstart may be worth looking into as well. However, you have to worry about application signing, warning messages, and other things.


instead of using <input type="file">, you can use CURL library to upload the file via POST. And this way you can pass the file path as parameter to your script. I haven't tried it myself though.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜