acidglitter Posted January 6, 2008 Share Posted January 6, 2008 I have this code to make an image (this is only the end of it..) header('Content-type: image/png'); imagepng($image_resized); imageDestroy($image_resized); But how can I use PHP to save this image to a folder on my website? Quote Link to comment https://forums.phpfreaks.com/topic/84680-solved-saving-an-image/ Share on other sites More sharing options...
thomashw Posted January 6, 2008 Share Posted January 6, 2008 Try using: <? $file = 'xxx' $newfile = 'xxx' copy($file, $newfile); $file is the source. $newfile is the destination. Quote Link to comment https://forums.phpfreaks.com/topic/84680-solved-saving-an-image/#findComment-431532 Share on other sites More sharing options...
helraizer Posted January 6, 2008 Share Posted January 6, 2008 I have this code to make an image (this is only the end of it..) header('Content-type: image/png'); imagepng($image_resized); imageDestroy($image_resized); But how can I use PHP to save this image to a folder on my website? header('Content-type: image/png'); imagepng($image_resized); // sends the image to the browser imagepng($image_resized, "resized_image.png"); // saves the image to the same folder as the script. (change the name accordingly) imagedestroy($image_resized); Hope that helps Sam Quote Link to comment https://forums.phpfreaks.com/topic/84680-solved-saving-an-image/#findComment-431536 Share on other sites More sharing options...
acidglitter Posted January 6, 2008 Author Share Posted January 6, 2008 I tried that but it didn't save it Quote Link to comment https://forums.phpfreaks.com/topic/84680-solved-saving-an-image/#findComment-431537 Share on other sites More sharing options...
helraizer Posted January 6, 2008 Share Posted January 6, 2008 I tried that but it didn't save it That's odd, because it should do. Put <?php error_reporting(E_ALL); ini_set('display_errors', true); ?> at the top of your code. Tell us if it returns any errors? EDIT: Are you running this script from the site you are wishing to save the image on? Sam Quote Link to comment https://forums.phpfreaks.com/topic/84680-solved-saving-an-image/#findComment-431542 Share on other sites More sharing options...
acidglitter Posted January 6, 2008 Author Share Posted January 6, 2008 oh the codes right but i didn't change the permissions for the folder. so its working now but how can i save it to a different folder? Quote Link to comment https://forums.phpfreaks.com/topic/84680-solved-saving-an-image/#findComment-431548 Share on other sites More sharing options...
helraizer Posted January 6, 2008 Share Posted January 6, 2008 oh the codes right but i didn't change the permissions for the folder. so its working now but how can i save it to a different folder? imagepng($image_resized, "./images/resized_image.png"); Along those lines with help. just change that last part to where you want to image to go to. (as long as you have write permissions for that folder it will go to it). Hope that helps? Sam Quote Link to comment https://forums.phpfreaks.com/topic/84680-solved-saving-an-image/#findComment-431550 Share on other sites More sharing options...
acidglitter Posted January 6, 2008 Author Share Posted January 6, 2008 okay thanks! Quote Link to comment https://forums.phpfreaks.com/topic/84680-solved-saving-an-image/#findComment-431554 Share on other sites More sharing options...
helraizer Posted January 6, 2008 Share Posted January 6, 2008 okay thanks! Glad I could help. Don't hesitate to ask again if you have any more problems. Sam Quote Link to comment https://forums.phpfreaks.com/topic/84680-solved-saving-an-image/#findComment-431555 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.