0
votes

I have a form wich you choose a file (a image) trough a input type file and it must upload that image to a folder. On my Computer (Running XAMPP) that works fine, but now I'm moving the projecto to my server because its finished.

My server runs Ubuntu 16.04 (Apache + PHP + MySQL). Apache Version: Apache/2.4.18 (Ubuntu) PHP Version: 7.0.4-7ubuntu2.1 MySQL Version: 5.7.12-0ubuntu1 - (Ubuntu)

What I've tried: -Give max permissions to the both files (the form file and the file where the post action is)

Upload Script:

<?php
$File = array("Name" => $_FILES['prod_image']['name'], "Error" => $_FILES['prod_image']['error'], "Size" => $_FILES['prod_image']['size'], "tmp_name" => $_FILES['prod_image']['tmp_name']);

move_uploaded_file($File['tmp_name'], "../images/".basename($File['Name']));
3
Do you get any errors? - Jay Blanchard
None! When I var_dump the move_uploaded_file function, it return bool(false). Otherwise you see a blankpage. - rui404
Have you checked the actual error logs? - Jay Blanchard

3 Answers

1
votes

I use this code to upload a file:

$your_Path="";//set your path, e.g., $_SERVER['HTTP_HOST']
$name='prod_image'; /
$userfile_tmp = $_FILES[$name]['tmp_name'];
$userfile_name = $_FILES[$name]['name'];
$userfile_size = $_FILES[$name]['size'];

if (move_uploaded_file($userfile_tmp, $your_Path. $userfile_name)) {
 echo 'Success.';
}else
  echo 'error'; 
}
0
votes

If you are experiencing file upload issues using Ubuntu then check your virtual host configuration file and comment out the 'REQUIRE ALL GRANTED'

e.g

 <Directory /var/www/your_project>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        #Require all granted
    </Directory>
0
votes

Check Your PHP Configuration Files and see the File Upload Section and change the File Upload Limit/Temp Directory. If the File Size is greater than the file upload limit the script will work but not produce any output. 2.Make sure the client has the necessary permissions to upload.