Hello, I have this script that I am trying to get to work! It doesnt seem to upload my file into the directory…the copy function doesnt seem to copy the temporary file into my directory within my site. I read PHP documentation and it seems right! Any suggestions? Here is the code
[code=php]
<?php
if ($HTTP_POST_VARS[‘submit’]) {
print_r($HTTP_POST_FILES);
if (!is_uploaded_file($HTTP_POST_FILES[‘file’][‘tmp_name’])) {
$error = “You did not upload a file!”;
unlink($HTTP_POST_FILES[‘file’][‘tmp_name’]);
// assign error message, remove uploaded file, redisplay form.
} else {
//a file was uploaded
$maxfilesize=102400;
if ($HTTP_POST_FILES[‘file’][‘size’] > $maxfilesize) {
$error = “file is too large”;
unlink($HTTP_POST_FILES[‘file’][‘tmp_name’]);
// assign error message, remove uploaded file, redisplay form.
} else {
if ($HTTP_POST_FILES[‘file’][‘type’] != “image/gif” AND $HTTP_POST_FILES[‘file’][‘type’] != “image/pjpeg”) {
$error = “This file type is not allowed”;
unlink($HTTP_POST_FILES[‘file’][‘tmp_name’]);
// assign error message, remove uploaded file, redisplay form.
} else {
//File has passed all validation, copy it to the final destination and remove the temporary file:
copy($HTTP_POST_FILES[‘file’][‘tmp_name’],”/images/”.$HTTP_POST_FILES[‘file’][‘name’]);
unlink($HTTP_POST_FILES[‘file’][‘tmp_name’]);
print “File has been successfully uploaded!”;
exit;
}
}
}
}
?>
<html>
<head></head>
<body>
<form action=”<?=$PHP_SELF?>” method=”post” enctype=”multipart/form-data”>
<?=$error?>
<br>
Choose a file to upload:<br>
<input type=”file” name=”file”><br>
<input type=”submit” name=”submit” value=”submit”>
</form>
</body>
it gives me this message:
[QUOTE]
Array ( [file] => Array ( [name] => Blue hills.jpg [type] => image/pjpeg [tmp_name] => /tmp/phppPcsU3 [error] => 0 [size] => 28521 ) )
Warning: copy(/images/Blue hills.jpg): failed to open stream: Permission denied in /home/content/v/i/c/vicpal25/html/test-area/upload.php on line 24
File has been successfully uploaded!
it gets to my validation of my if & else to say uploaded but nope! it doesnt! my diretory is set to chmod 777! Any suggestions?