简体   繁体   中英

php multi file upload without html form

I'm developing a system that contains a folder with XML file and image files. I want user to be able to upload all of the images and XML file.. This is more like a backup for the user.. But I don't want the user to choose hundreds of files one by one..

I've tried many php codes but they are all based on one file upload. How can I upload all of the files in the folder without asking anything from user (no input or button).. and I'm not using any HTML file.

I tried to "scandir" with php and use it for uploading file but couldnt make it work. It should be something with "scandir" or maybe some Java integration

You do realize that scandir() would only scan directories on your server, right? PHP executes on the server, not in the client browser.

There is nothing you can do in HTML that would let you get access to a user's directory structure, without exploiting browser security flaws.

As well, using a <input type="file"...> tag is the only method to allow file uploads. Even then, you have minimal control over the tag. They're nearly impossible to style, they allow only minimal information to be available via javascript, etc... HTML5 does allow multi-file uploads in a single tag, but until HTML5 browsers become more commonplace, you're stuck with the old-schoole one-file-per-input method.

As others have stated, HTTP is not the ideal file transfer mechanism. Why can't you use ftp or ssh2? PHP has libraries for both of these. PHP also has a zip library, so you could zip all of the files and send it as one over http as well if they are small enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM