I have been following a video tutorial on how to make an image upload website, but he hasn't finished it yet and I went to get it done tonight.
index.php code:
if($type = "video/avi") //conditions for the file
{
die("That format is not allowed");
}
else
{
move_uploaded_file($temp,"uploaded/".$name);
echo "Upload complete";
}
}
?>
At the moment the file you upload goes into the uploaded folder, but it does not show the user who uploaded the file the image.
if ($error > 0) { die("Error uploading file! Code $error."); } else { if(move_uploaded_file($temp,"uploaded/".$name)) { echo "Upload complete"; } else { echo "Failed to complete the upload"; } }
used that and it fixed the problem, but it still doesnt show the uploader the picture, it just shows "Upload Complete" which is should, but I want the image also. It shows the image in the "uploaded" folder when I view it in FileZilla.
I'd strongly suggest you learn the basics of PHP so you understand what is happening and can modify the script accordingly.
Go to Tizag.com and run through the php tutorials as you really should be able to read the code and have it read out the address. If you can't do that then you shouldn't be delving into PHP.
if ($error > 0) {
die("Error uploading file! Code $error.");
} else {
$ext = strtolower(substr($name, strrpos($name, "."))); // Get Extension
$newname = time().rand(100,999).$ext; // Generate Random File Name
if(move_uploaded_file($temp,"uploaded/".$newname)) {
?>
<!-- Start Success HTML -->
Upload complete <br/><br/>
<img src="uploaded/<? echo $newname; ?>" alt="Uploaded Image">
<!-- End Success HTML -->
<?
} else {
echo "Failed to complete the upload";
}
}
?>
Originally Posted by jassinc
I'd strongly suggest you learn the basics of PHP so you understand what is happening and can modify the script accordingly.
Go to Tizag.com and run through the php tutorials as you really should be able to read the code and have it read out the address. If you can't do that then you shouldn't be delving into PHP.
Thanks but I got it to work, it was something I didn't get but with a little tweaking it works how I want it to now.
Bookmarks