0

Am using this code(shown below) 4 uploading an image.
while using this getting an error like 'there was an error moving the uploaded file"

what could be the reason for this?
Though an error occurs,am still able to upload the image successfully. ie the image is saved at tha intended loaction.


code....


if($_POST["action"] == "Upload Image")
{
unset($imagename);

if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;

if(!isset($_FILES))
$error["image_file"] = "An image was not found.";


$imagename = basename($_FILES);
//echo $imagename;

if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";

if(empty($error))
{
$newimage = "images/" . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES, $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
}

}

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by effu
0

Change this:

if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";

To this:

if(!$result)
$error["result"] = "There was an error moving the uploaded file.";

The $result variable should be true if the file is moved successfully.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.