rui404 rui404 - 10 months ago 54
PHP Question

Upload PHP Script not working in Ubuntu

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:

$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']));

Answer Source

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.';
  echo 'error';