This is the upload form
<html>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="uploaded" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
And this is the php:
<?php
$keys = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for ($i = 0; $i < 10; $i++) {
$photoID .= $keys[rand(0, strlen($keys)-1)];
}
//add a dot (.) to the randomly generated string so the ext can be applied to it later
$photoID2 = $photoID.".jpg";
//This assigns the subdirectory you want to save into... make sure it exists!
$target = "uploads/";
//This combines the directory, the random file name, and the extension
$target = $target . $photoID2.$ext;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
echo "The file has been uploaded as ".$photoID2.$ext;
} else {
echo "Error: upload did not work";
}
?>
The problem I have is that i keep getting the error upload did not work... what am I doing wrong here ? it's really basic something that I am missing but i need to understand it because I can already do file uploads fine but want to understand how it works...