Here is a link that may lead you to an answer you seek. https://code.google.com/p/html5uploader/[^] This should allow users of your site to drag and drop a file from their OS to be uploaded to your site in their browser. This will create a button to 'browse' but then they should not have to click an upload button and therefore you should not have to display an upload button. You can have it save to a 'dynamic' directory/folder by manipulating the save directory in the PHP page that is shown on that site's page. Let's assume that that want files save into a directory named after the user but all user's folders are inside a directory called user_uploads. You will have to set it to an "id" that, obviously, would be unique to each user of your site. If users have a unique username then it could be $username
or if they have a unique ID number associated with their account then it could be $user_id
. First change the name of the upload folder to what you want...as described above I am going with user_uploads:
$upload_folder = 'user_uploads';
Then you would have to do an additional change to the lines shown below to add it to the dynamic folder with the user's unique ID.
if(file_put_contents($upload_folder/$username.'/'.$headers['UP-FILENAME'], $content)) {
echo 'done';
}
For safety's sake I would either create a new directory named with a registering members unique ID upon creation of a new account or at least right before the second code shown to make sure that they actually have an existing directory to download into. Although it might be better to go with the second option here as you may have a lot of members who do not want to upload anything and therefore you could end up with a whole lot of empty directories sitting in that parent directory. Creating the directory (with appropriate permissions to store and show images) right before the upload process could ensure that only those users/members that actually want to upload something will have a folder. You can download the 3 files plus the .js file from that link above. However, the link to demo this in action appears to be broken. But it's pretty simple and straightforward so it shouldn't take too much work to change a couple variables, upload to your server and test it yourself. If