here you go try this... but If i were you should write your own so you understand it better....
Code:
<?php
error_reporting(E_ALL ^ E_NOTICE); // Show all major errors.
// Check to see if the button has been pressed
if (!empty($_REQUEST['sendForm']))
{
// Assign the name to a variable
$name = $_FILES['uploaded_file']['name'];
// Assign the tmp_name to a variable
$tmp_name = $_FILES['uploaded_file']['tmp_name'];
// Assign the error to a variable
$error = $_FILES['uploaded_file']['error'];
// Assign the size to a variable
$size = $_FILES['uploaded_file']['size'];
// No trailing slash, folder where you want it uploaded too
$uploadFilesTo = ' THE FOLDER ITS UPLOADED TO!! ';
// Create safe filename
$name = ereg_replace('[^A-Za-z0-9.]', '-', $name);
// Disallowed file extensions
$naughtyFileExtension = array("php", "php3", "asp", "inc", "txt", "wma", "mov", "js", "exe", "jsp", "map", "obj", "gif", " ", "", "html", "mp3", "mpu", "wav", "cur", "ani");
// Returns an array that includes the extension
$fileInfo = pathinfo($name);
// Check extension
if (!in_array($fileInfo['extension'], $naughtyFileExtension))
{
// Get filename
$name = getNonExistingFilename($uploadFilesTo, $name);
// Upload the file
if (move_uploaded_file($tmp_name, $uploadFilesTo.'/'.$name))
{
// Show success message
echo '<center><p>File uploaded to /'.$uploadFilesTo.'/'.$name.'</p></center><meta http-equiv="Refresh" content="0; URL=http://www.yoursite.com/folder thats its uploaded too">';
}
else
{
// Show failure message
echo '<center><p>File failed to upload to /'.$name.'</p></center>';
}
}
else
{
// Bad File type
echo '<center><p>The file uses an extension we don\'t allow.</p></center>';
}
}
// Functions do not need to be inline with the rest of the code
function getNonExistingFilename($uploadFilesTo, $name)
{
if (!file_exists($uploadFilesTo . '/' . $name))
return $name;
return getNonExistingFilename($uploadFilesTo, rand(100, 200) . '_' . $name);
}
?>
<table bgcolor="gray" border="1"><tr>
<tr><td>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="uploaded_file"><br>
<input type="submit" name="sendForm" value="Upload Image">
</form>
</td></tr>
</table>
here is a upload script that does not use mysql all you have to do is find a way to have it populated or how ever you want.. but I think mysql might be the besy way to keep tract of things...
Bookmarks