PHP File Upload to Current Folder
Posted on 2004-11-24
I'm trying to upload an image to a folder using php.
I've got a very simple form.
<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']?>">
<input type="file" name="userfile"><br/>
<input type="submit" value="Upload">
I just want to save the file that the user uploads, to a sub-folder under where this script is, called uploaded_images. I'd like to keep the filename the same as what the user enters. If the file already exists, then append a timestamp or something to the filename, or even a sessionid to keep it unique.
I'm running PHP5 on Apache2 on Windows XP.
This is only so that some of my friends can upload files to me from various locations where they have limited internet access. I'll worry about security and stuff later on.
Thanks if anyone can help. And if anyone gives complete code in one full page I'll double the points.