PHP will save files to one folder but not another
PHP will save files to one folder but not another
I am making a phonegap app that includes uploading to a linux server running the LAMP stack.
I have a file called upload.php which contains the following code:
<?php
header('Access-Control-Allow-Origin: *');
$new_image_name = urldecode($_FILES["file"]["name"]).".jpg";
move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/".$new_image_name);
?>
and inside /var/www/html/ I have a folder called uploads with 777 permissions just for testing purposes. This code works perfectly and saves the files in /var/www/html/uploads/. I then created another folder called images within the html folder and it also has 777 permissions but the file will refuse to save in this folder when I run this version of upload.php:
<?php
header('Access-Control-Allow-Origin: *');
$new_image_name = urldecode($_FILES["file"]["name"]).".jpg";
move_uploaded_file($_FILES["file"]["tmp_name"], "images/".$new_image_name);
?>
It may be worth noting that I can also save to directories inside /var/www/html/uploads/ such as /var/www/html/uploads/images/
Both folders are set up with the exact same permissions and owners @akshaypjoshi
– Theo Michail
Sep 2 at 9:26
is there in
/var/www/
or in /var/www/html/
or in /var/www/html/uploads/
an .htaccess
file (hidden)?– Andra
Sep 2 at 10:31
/var/www/
/var/www/html/
/var/www/html/uploads/
.htaccess
@Andra no there aren't any hidden files in any of those directories
– Theo Michail
Sep 2 at 10:36
permissions in the virtual host config file?
– Andra
Sep 2 at 10:41
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Check ownership of both the folders.
– akshaypjoshi
Sep 2 at 9:18