I'm trying to get a very basic PHP upload script to work.
This is what I have in my HTML page:
<form enctype="multipart/form-data" action="/ftp/upload.php" method="POST">
Select your file to upload:<br><br> <input name="uploaded" type="file" />
<br><br><br><input type="submit" value="Upload" />
</form>
This is my upload.php file:
<?php
$target = "/ftp/Ducati Tuning/Uploads/";
$target = $target . basename( $_FILES['uploads']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type =="bin/xdf/txt")
{
echo "You may only upload .BIN, .XDF, & .TXT files!<br>";
$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['uploads']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.;
}
}
?>
Can anyone spot my mistake? It's driving me nuts lol. I have the Uploads directory which is my file dstination folder set for 777 on the permissions already. Perhaps I need to do something with a .htaccess file on my server too? I'm using GoDaddy. In my PHP config File Uploads is turned on and the session /tmp is also set to 777.
Any help is greatly appreciated in advance! Thanks!
Question
anguilla1980
I'm trying to get a very basic PHP upload script to work.
This is what I have in my HTML page:
This is my upload.php file:
Can anyone spot my mistake? It's driving me nuts lol. I have the Uploads directory which is my file dstination folder set for 777 on the permissions already. Perhaps I need to do something with a .htaccess file on my server too? I'm using GoDaddy. In my PHP config File Uploads is turned on and the session /tmp is also set to 777.
Any help is greatly appreciated in advance! Thanks!
Alex
Link to comment
Share on other sites
13 answers to this question
Recommended Posts