I found this useful script on php.net and its helped me check our new server work (or not) with upload.
Customise and make sure the file permissions are okay for the directory you want to move the file too.
WARNING
We never run this script on an insecure/production box as it has no checking on the file type and so someone could upload something dangerous.... oooh!
<?php
//print_r($_POST);
if($_POST["action"] == "Upload Image")
{
unset($imagename);
if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;
if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";
$imagename = basename($_FILES['image_file']['name']);
//echo $imagename;
if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";
if(empty($error))
{
$newimage = "" . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result)) {
$error["result"] = "There was an error moving the uploaded file.";
print_r($_FILES);
} else
echo "<img src='".$newimage."' border=0>";
}
}
?>
<form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?php $_SERVER["PHP_SELF"];?>">
<p><input type="file" name="image_file" size="20"></p>
<p><input type="submit" value="Upload Image" name="action"></p>
</form>
<?php
if(is_array($error))
{
while(list($key, $val) = each($error))
{
echo $val;
echo "<br>\n";
}
}
?>
Posted by Ben
Matter Solutions - web techies for web designers
http://www.mattersolutions.com