Hi,
I'm trying to make a upload page on my website to let freinds upload files to my host.
I don't understand why it doesn't work. Do you know if there is a restriction?
I do the test with a smal file, when I submit the upload I get my the echo of my error message. "Sorry, there was a problem uploading your file. "
in the log file I have : [Mon Oct 10 14:27:00 2011] [error] [client 160.53.250.126] File does not exist: /home/$user/public_html/500.shtml, referer:
http://dn.com/upload/here is the page :
I create the folder uploads/upload
<form action='uploads/upload.php' method='post' enctype='multipart/form-data'>
<p> Récupérer un fichier sur votre poste de travail : </p>
<input name='uploads[]' type='file'>
<input name='uploads[]' type='file'>
<input name='uploads[]' type='file'>
<input name='uploads[]' type='file'>
<input name='uploads[]' type='file'>
<input name='uploads[]' type='file'>
<input type='submit' value='Fichier enregistré sur le serveur'>
</form>
I create the php script, see below :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="fr" xmlns="
http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta ch#%$!t="UTF-8" />
<title>Eugénie Decré</title>
</head>
<body>
<?php
$target = "uploads/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size > 350000000)
{
echo "Your file is too large.
";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files
";
$ok=0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
<p> </p>
<p> </p>
</body>
</html>