Change "tmp" dir for uploading file - PHP / Upload / Editor

Change "tmp" dir for uploading file - PHP / Upload / Editor

Brandon_Voorvelt01Brandon_Voorvelt01 Posts: 3Questions: 2Answers: 0

Hi All,

I'm trying to upload an image using the Editor PHP library.

Following the manuals, I have got it down pretty well (Allan you are a legend!!)
When uploading, traditionally, the file is stored in the temp folder before it's moved to the actual folder/database.

My only issue now is, my back-end guys have removed all permissions for the "tmp" folder on the server. :(
So when I try to create/edit (haven't tried remove) the image using Editor - I get this error:

"A server error occurred while uploading the file".

Checking the response in the inspector, this is printed out: (I took out my server root)

Warning: move_uploaded_file(..../uploads/lts.png): failed to open stream: Permission denied in /..../dist/lib/Editor/Upload.php on line 488

Warning: move_uploaded_file(): Unable to move '/tmp/phpXDWwY4' to '..../uploads/lts.png' in /***/dist/lib/Editor/Upload.php on line 488

Is there a way to change the temp folder directory in the Upload instance? Perhaps somewhere here:
->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/uploads/__NAME__' )

Answers

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Allan you are a legend

    What a nice way to start the weekend - thank you :).

    My only issue now is, my back-end guys have removed all permissions for the "tmp" folder on the server

    Are you sure that it is the /tmp dir that they've revoked access to (which would be a really odd thing to do imho) and not the destination directory? ..../ is a somewhat odd directory path start - it might well be related to that rather than /tmp permissions.

    Try using an absolute path instead:

    ->upload( Upload::inst( '/home/myUser/www/uploads/__NAME__' )
    

    I'd be interested to know what:

    var_dump( $_SERVER['DOCUMENT_ROOT'] );
    

    returns...

    Allan

  • Brandon_Voorvelt01Brandon_Voorvelt01 Posts: 3Questions: 2Answers: 0

    Thanks for your reply Allan, I changed to the absolute path but got the same error back.

    Are you sure that it is the /tmp dir that they've revoked access to (which would be a really odd thing to do imho) and not the destination directory?

    Yip, they have restricted access on majority of the server....Making my job a lot harder :s

    ..../ is a somewhat odd directory path

    Sorry I just used this in place of the actual path

    var_dump( $_SERVER['DOCUMENT_ROOT'] );

    Doing the var_dump returns: string(34) "/var/www/html/the_main_directory" (I've just changed the name of the directory)

    It seems the 'tmp' folder is not located in the above directory. I saw it is located somewhere here: /var/www/html/tmp instead. I created a tmp dir now here:
    /var/www/html/the_main_directory/tmp. Could I change the tmp folder path to this in Editor? (I don't have access to the php.ini file)

Sign In or Register to comment.