0

i've tried searching but couldn't find the answer to my issue - i'm trying to upload an image and getting the following error.

This is my error log:

PHP Warning: move_uploaded_file(): Unable to move '/tmp/php19Ivqt' to '/var/www/vhosts/domain.co.uk/httpdocs/img/cms/20160115_090216.jpg' in /var/www/vhosts/domain.co.uk/httpdocs/admin813khufbl/filemanager/upload.php on line 71


upload.php - line 69-71 is:

if ($is_img) {
    move_uploaded_file($tempFile, $targetFile);
    chmod($targetFile, 0777);
}
mitkosoft
  • 5,262
  • 1
  • 13
  • 31
Tom
  • 9
  • 1
  • Either the directory doesn't currently exist or there is not enough permissions to write within that folder at: /var/www/vhosts/domain.co.uk/httpdocs/img/cms/ – jjonesdesign Apr 12 '16 at 09:20
  • Possible duplicate of [PHP Warning: move\_uploaded\_file() unable to move](http://stackoverflow.com/questions/13723174/php-warning-move-uploaded-file-unable-to-move) – Chris Apr 12 '16 at 09:21
  • OK, i've managed to get it uploading via changing the permissions on cms to 777... however this has now given a new error... Parse error: syntax error, unexpected 'class' (T_CLASS) in /var/www/vhosts/domain.co.uk/httpdocs/admin813khufbl/filemanager/include/php_image_magician.php on line 164 Line 163 class imageLib Line 164 { Line 165 private $fileName; Line 166 private $image; – Tom Apr 12 '16 at 09:32
  • @Tom If you have a new problem please make a new question. I think you will find the solution can be found [here](http://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) though. – Chris Apr 12 '16 at 09:53

2 Answers2

0

Make sure folder /var/www/vhosts/domain.co.uk/httpdocs/img/cms/ exists.

Also make sure the file permissions are set properly for Writing.

jjonesdesign
  • 410
  • 2
  • 14
-1

Try this bellow code for upload files in new created directory.

<?php
    define("SITE_NAME","project_name/"); //constant for project name
    define("SITE_PATH",$_SERVER['DOCUMENT_ROOT']."/".SITE_NAME); //constant for project base directory
    define("IMAGES_URL",SITE_URL."images/"); //constant for image directory


    $upload_base_dir=IMAGES_URL;
    $upload_time_dir=date('Y')."/".date('m')."/".date('d')."/"; // setup directory name
    $upload_dir = $upload_base_dir.$upload_time_dir;

    if (!file_exists($upload_dir)) {
        mkdir($upload_dir, 0777, true);  //create directory if not exist
    }

    $image_name=basename($_FILES['image']['name']);
    $image=time().'_'.$image_name;
    move_uploaded_file($_FILES['image']['tmp_name'],$upload_dir.$image); // upload file
?>