uploading file to server is always giving me this error though I tried all solution on the web for this problem but I'm still getting this error no matter what :
Warning: move_uploaded_file(/home/safaa/uploads/d.txt): failed to open stream: Permission denied in /var/www/html/Administration/newEmptyPHP.php on line 47
Warning: move_uploaded_file(): Unable to move '/tmp/php6qK4Df' to '/home/safaa/uploads/d.txt' in /var/www/html/Administration/newEmptyPHP.php on line 47
Here's my HTML code :
<form id="file_to_upload" name="file_to_upload" enctype="multipart/form-data" action="newEmptyPHP.php" method="post" >
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Browse for a root certificate to upload:
<input type="file" name="uploaded_file">
<input type="submit" value="Upload It Now" onclick="$('#file_to_upload').submit();">
</form>
my PHP code :
$file_name = $_FILES["uploaded_file"]["name"];
//User can upload only till 100kb file size.
$file_tmp_name = $_FILES["uploaded_file"]["tmp_name"];
$upload_path = "/home/safaa/uploads/" . $file_name;
//function for upload file
if (move_uploaded_file($file_tmp_name, $upload_path)) {
echo "Successful<BR>";
}
I've tried these following solutions which they are all what I found on the web forums and stackoverflow questions and answers :
- Change permission of /tmp/ and /uploads/ to 777 and 0777 . "it didn't work"
- in php.ini , safe mode is off and file_uploads is on
- SELinux is Disabled :: getenforce gave me Disabled
drwxrwxrwx. 6 nobody root 4096 Jul 20 13:06 tmp drwxrwxrwx 2 nobody safaa 4096 Jul 17 15:17 uploads
neither of both worked .