I am trying to upload files to my server through a CRUD. I am having an issue moving the uploaded file to its new directory which exists.
I am receiving this warning..
Warning: move_uploaded_file(../images/me.png): failed to open stream: Permission denied in /var/www/html/admin/addpicture.php
Warning: move_uploaded_file(): Unable to move '/tmp/phpHQ6U5X' to '../images/me.png'
Realizing this might be a permission issue with /tmp, I decided to change the temporary upload folder.
I set a temporary upload folder in the php.ini file I found listed in phpinfo()
Configuration File (php.ini) Path /etc/php/7.0/apache2
I restarted my server using
sudo systemctl restart apache2
I checked to make sure my changes were set with phpinfo() again
upload_tmp_dir /var/www/html/upload_tmp
Also, I checked to see if my basedir is set
open_basedir no value
I tried to upload the file again
Warning: move_uploaded_file(): Unable to move '/tmp/phpHQ6U5X' to '../images/me.png'
I am including code for completeness but I can confirm that this code works for me on localhost and other servers I have worked on.
PHP
if(isset($_FILES) & !empty($_FILES)){
$name = $_FILES['pictureimage']['name'];
$size = $_FILES['pictureimage']['size'];
$type = $_FILES['pictureimage']['type'];
$tmp_name = $_FILES['pictureimage']['tmp_name'];
$max_size = 10000000;
$extension = substr($name, strpos($name, '.') + 1);
if(isset($name) && !empty($name)){
if($size<=$max_size){
$location = '../images/';
$filepath = $location.$name;
if(move_uploaded_file($tmp_name, $filepath)){
HTML
<input type="file" name="pictureimage" id="pictureimage">
What am I missing? Why would the form continue to upload to /tmp instead of the upload_tmp_dir that I set?