PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Im very new to the world of PHP and found a nice piece of code to allow file uploads, well it would be nice if it worked!
I have a HTML page that allows the user to browse for a file, when the "Upload" button is pressed the information is passed to my test.php page. Unfortunately i keep getting an error warning error:
Warning: move_uploaded_file(/home/fhlinux200/j/jameson-groves.co.uk/user/Yoda.jpg): failed to open stream: Permission denied in /home/fhlinux200/j/jameson-groves.co.uk/user/htdocs/test/test.php on line 9
Warning: move_uploaded_file(): Unable to move '/tmp/phptmOb5R' to '/home/fhlinux200/j/jameson-groves.co.uk/user/Yoda.jpg' in /home/fhlinux200/j/jameson-groves.co.uk/user/htdocs/test/test.php on line 9
Possible file upload attack!
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/home/fhlinux200/j/jameson-groves.co.uk/user/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
or you can do it manually through most FTP clients ;d
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Warning: chmod(): No such file or directory in /home/fhlinux200/j/jameson-groves.co.uk/user/htdocs/test/test.php on line 10
File is valid, and was successfully uploaded.
Its now working. Interestingly it may have been working before as it was only a warning message.
Can someone tell me, does the chmod($upload_dir, 0777); bit only have to be run once just to give the folder permissions?
Cheers again
only needs to be run once
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.