So, here is my basic file structure:
- public_html/
--index.php
---php/
---imageUpload.php
--uploads/
I have got a PHP script which works fine, up until it comes to execute imagejpeg()
command, this is what mine looks like:
imagejpeg($images_fin,"../uploads/".$new_images); //Save image to file
Obviously I have got ../
as I want to go back a folder, as uploads/
is in the root directory. If I try that though I get this error:
PHP Error Message Warning: imagejpeg() [function.imagejpeg]: Unable to open '../uploads/' for writing: Is a directory in /home/a9990485/public_html/php/uploadImage.php on line 42
However, if I change my imagejpeg to this:
imagejpeg($images_fin,"..\uploads\\".$new_images); //Save image to file
It just creates a new folder called ..\\uploads\\\\
in my php/
folder and the image saves in there. What is going on, why can't I go back into my root directory and save it in my uploads folder!
I have tried $_SERVER['DOCUMENT_ROOT']."/public_html/uploads/"
but I get an error saying I have no access to the folder than as i'm assuming it's trying to go too far back into the hosts file structure.
probable reason for this is $new_images variable is empty. The php error says
Unable to open '../uploads/' for writing
which means it is trying to open ../uploads/ which is a folder and not a file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.