简体   繁体   中英

imagejpeg save file does not work

I managed to display image on browser but I cannot save it using imagejpeg (I don't see any image saved in the server). I have been trying for hours and also tested out the folder by using is_writable as mentioned in this post asked by someone else PHP imagejpeg save file doesn't work . But it still doesn't work and on chrome, I don't see any error except broken image icon but on IE, it shows error like this " : imagejpeg() [function.imagejpeg]: Unable to open" the file is not writable :imagejpeg()[function.imagejpeg]:无法打开”文件是不可写

Here is my code.

header('Content-type: image/jpeg');
$filename = 'little.jpg';
 $im = imagecreatefromjpeg($filename); 
imagefilter($im, IMG_FILTER_CONTRAST,$_POST["amount"]);

imagejpeg($im,"test.jpg");   

imagedestroy($im); 

if (is_writable('test.jpg')) {
    echo 'The file is writable';
} else {
    echo 'The file is not writable';
}

Anyone can help,please? thank you. PS: I also want to display the image on the browser and save the image at the same time. Is imagejpeg able to do it? If not, is there better way to do it? Thank you.

Edit: When I checked whether my folder is writable, it echoed 'the file is writable' but when I checked whether test.jpg is writable, it echoed 'the file is not writable'.

That error indicates that your PHP script does not have permission to write to that location on the server. Use your FTP software to CHMOD (change permissions) to allow write to the directory you are trying to store these in. That should do it unless your webhost has disabled PHP from writing files locally at all (in which case, you should talk to them and see what options are available).

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM