Search HouseOfScripts.com

 

All Scripts        JavaScripts        ASP Scripts        Other Scripts

 

  Upload file using PHP script

I spent a long time searching on the Internet trying to figure out how to upload files using php form. I tried a few diferent scripts but only this one worked for me. Also there was one imprortant step that was missed - you have to create and CHMOD "upload" directory to 777.

Create a file and call it supload.php. Erase everything and copy and paste the following script.

<html>
<head>
<title>Upload file using PHP script</title>
</head>
<body>
<?php
if($File) // if file exists
{
print "File Name: $File_name<p>\n";
print "File size: $File_size<p>\n";
if (copy($File, "upload/$File_name"))
{
print "Your file was uploaded successfully! <p>\n";
}
else
{
print "Was unable to upload file <p>\n";
}
unlink ($File); // deletes file
}
print "Upload a file to the server: \n";
print " <form method=\"post\" action=\"supload.php\" enctype=\"multipart/form-data\"> \n";
print "File <input type=\"file\" name=\"File\" size=40><br> \n";
print "<input type=\"submit\" value=\"Submit\"></form> \n";
?>
</body>
</html>

 


Home       Scripts       Active WebTools       Web Templates       Forum       Tools        Hosting       Questions/Comments       Add/Request