Everything seems to work but nothing does. The test page is Upload Test. I would like to get this working before I incorporate it into a page that adds a classified ad to a database. I have a few print lines below just to make sure I was getting something but I am not getting a tmp_name. Maybe I just don't understand what I am doing but I have written some Nice pages that write to a DB and retrieve the information. Click on the Free Ad button to test it and the search works too.
Here is my upload code:
if (isset($_POST['submit']))
{
$file = $_FILES['upload']['name'];
$t_file = $_FILES['upload']['tmp_name'];
$extension = explode ('.', $_FILES['upload']['name']);
$uid = "19"; // Upload ID
$filename = $uid . '.' . $extension[1];
print $file;
print $t_file;
print $filename;
// Move the file over.
if (move_uploaded_file($_FILES['upload']['tmp_name'], "/images/$filename"))
{
echo '<p>The file has been uploaded!</p>';
}
else
{ // If the query did not run OK.
echo '<p><font color="red">Your submission could not be processed due to a system error. We apologize for any inconvenience.</font></p>';
}
}
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="100">
<fieldset><legend>Fill out the form to upload a file:</legend>
<p><b>File:</b> <input type="file" name="upload" /></p>
<p><b>Description:</b> <textarea name="description" cols="40" rows="5"></textarea></p>
</fieldset>
<div align="center"><input type="submit" name="submit" value="Submit" /></div>
</form><!-- End of Form -->
I think something may not be right with the path but I have tried variations that I have read about in books. The destination folder is one level below where this page/code will reside.
Help 🙂