If the text over here gets messed up
$ cat pv.html
$ cat upload.php
$target_dir = "/var/www/uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
echo "The value of target directory is =" . $target_dir . "";
echo "The value of target file is =" . $target_file . "";
echo "The value of uploadOk is =" . $uploadOk . "";
echo "The value of imageFileType is =" . $imageFileType . "";
echo "Upload: " . $_FILES["fileToUpload"]["name"] . "
";
echo "Type: " . $_FILES["fileToUpload"]["type"] . "
";
echo "Size: " . ($_FILES["fileToUpload"]["size"] / 1024) . " Kb
";
echo "Temp file: " . $_FILES["fileToUpload"]["tmp_name"] . "
";
echo "Error :" . $_FILES["fileToUpload"]["error"] . "
";
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
$finfo = finfo_open(FILEINFO_MIME_TYPE);
echo " The value of finfo is =" . $finfo . "";
echo finfo_file($finfo, $target_file );
finfo_close($finfo);
?>
Reference
http://php.net/manual/en/features.file-upload.php
To find out error codes.
http://php.net/manual/en/features.file-upload.errors.php
No comments:
Post a Comment