Here is the script:
<?php
$MAX_SIZE = "2000000"; // Max size of file (in bytes)
$file_dir = "your_upload_dir"; // Path to the upload dir
$file_url = "http://www.yourhost.com/your_upload_dir"; // URL to the upload dir
$show_img = "1"; // If an images is uploaded, will it be shown?! Set this to 1 or 0.
if(isset($fupload))
{
print "<b>Upload Info:</b><br>\n";
print "<b>path:</b> $fupload<br>\n";
print "<b>name:</b> $fupload_name<br>\n";
print "<b>type:</b> $fupload_type<p>\n\n";
if($fupload_type == "image/gif")
{
copy($fupload, "$file_dir/$fupload_name") or die ("Couldn't copy");
if($show_img == "1")
{
print "<img src=\"$file_dir/$fupload_name\"><p>\n\n";
}
else
{
print "";
}
}
else if($fupload_type = "image/jpeg")
{
copy($fupload, "$file_dir/$fupload_name") or die("Copy failed.");
if($show_img == "1")
{
print "<img src=\"$file_dir/$fupload_name\"><p>\n\n";
}
else
print "";
}
}
}
?>
<html>
<head>
<title>Simple File Upload Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form enctype="multipart/form-data" action="<?php print $PHP_SELF; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="<?=$MAX_SIZE;?>">
<input type="file" name="fupload"><br>
<input type="submit" value="upload!">
</form>
</body>
</html>
Right now only gif- and jpeg-files are allowed to be uploaded, but this can be changed quite easily, all you have to know is the mime types for the files...
It worked when I tested it. Please let me know if it works for you to!