
upload
By: a guest on
Jun 21st, 2012 | syntax:
PHP | size: 0.87 KB | hits: 19 | expires: Never
<?
if ( isset ($_POST['action']) ) {
if($_POST['action'] == "Upload Image") {
unset($imagename);
if(!isset($_FILES) && isset($HTTP_POST_FILES)) $_FILES = $HTTP_POST_FILES;
if(!isset($_FILES['fileUpload'])) $error["image_file"] = "An image was not found.";
$imagename = basename($_FILES['fileUpload']['name']);
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['fileUpload']['tmp_name'], $newimage);
if ( empty($result) ) $error["result"] = "There was an error moving the uploaded file.";
}
}
} else {
echo "no form data found";
}
?>