Sava’s Single File Upload Script
Single file upload script. All the variables can be easily changed to suit your needs: – maximum file size that can be uploaded – allowed file extensions of files that are uploaded Easy to integrate into any design as it is very easy to remove it’s css and use your own. You can also view a list of the uploaded files. Single click file delete
I rewrote the code so that the notices Commander Killbot asked me about no longer appear.
No Demo | Download (2.35KB) ( 20732 downloads )
13 Responses to “Sava’s Single File Upload Script”
Looks good, was just wondering how safe this was to use. Is it safe enough to allow visitors to use it without worrying about the safety of my site?
Very nice! 😀
I need to upload a directory, can u help me in some way?
Hi, that’s me again.
i need to put upload.php inside directory (root/dir)
i dont know php, i try this at line 22
$url_dir = “http://”.$_SERVER[‘HTTP_HOST’].”/DIRR”.dirname($_SERVER[‘PHP_SELF’]);
but it says “change permission to 777 failed.” when i click on UPLOAD.
Hope u can help me
Fabio, you have to chmod to 777 the directory in which you try to upload.
For example you want to upload into directory “files” then you have to create “/root/files” directory and chmod it to 777.
Thanks for the script – I’m using it with XAMPP on a SuSE box and it seems to be working for both uploads and deletes, but I’m getting error notices like this:
Notice: Use of undefined constant del – assumed ‘del’ in /opt/lampp/htdocs/upload/upload.php on line 42
Notice: Undefined index: del in /opt/lampp/htdocs/upload/upload.php on line 42
Notice: Undefined index: userfile in /opt/lampp/htdocs/upload/upload.php on line 54
Notice: Undefined index: userfile in /opt/lampp/htdocs/upload/upload.php on line 76
Notice: Use of undefined constant message – assumed ‘message’ in /opt/lampp/htdocs/upload/upload.php on line 131
Since the script is working, this is not of vital importance, but can you help me figure out what’s going on with the notices?
Commander Killbot. I forgot to reply to your comment. The script has been rewritten. The notices will not appear if you download the new archive.
When a user uploads the same file name it overwrites the original file. I need it to rename the new file instead.
Locate this line in upload.php:
$file_name = str_replace(“‘”,””,$file_name);
and add these 2 lines right after it:
$new_file_name = explode(‘.’, $file_name);
$file_name = $new_file_name.date(‘YmdHis’).’.’.$new_file_name;
This way no uploaded file will ever have the same name.
I grabbed your script and I get this back:
Warning: opendir(gsmanga.pinochan.net/BOA/files) [function.opendir]: failed to open dir: No such file or directory in /home/.peggy/gsmanga/gsmanga.pinochan.net/BOA/upload/upload.php on line 96
Warning: readdir(): supplied argument is not a valid Directory resource in /home/.peggy/gsmanga/gsmanga.pinochan.net/BOA/upload/upload.php on line 101
Any help? I do have that directory and I did CHmod it to 777 like it said in your instructions. I am trying to allow people to upload music files for an online jukebox for my site…
Clicking on View (Action -> View file) gives me the following url:
Why is there a \ in the url?
Not sure. If you made any modifications download the script again.
This is the code that generated that link:
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$upload_url = $url_dir."/files/";
No \ there
Hi, 2 questions:
a) $upload_url = $url_dir.”/uploads/”; should be a ## User edited variables ## ?
b) i can’t remove files