|
Posted by NathanielGuy#21 on 01/30/05 19:11
Ah, thank you. after checking that the folder was there I found I had
made a mistake in the path to the folder. 8_ I can believe I didnt
find it before. Aside from that error, did I go about the image
resizing and everything in the correct way? What is the use of
imagecreatetruecolor(). Thanks for the help.
--nathan
On Sun, 30 Jan 2005 00:52:06 -0800, hitek <hitek@cox.net> wrote:
> Are you making sure the $_SESSION['user_sn'] folder exists before saving
> the image into it?
> I'm asking because I originally thought it was a permission problem but php
> will tell you 'permission denied' if that was the case.
>
>
> At 05:05 PM 1/29/2005, NathanielGuy#21 wrote:
> >Hello everyone,
> >I have been troubleshooting a problem with one of my scripts for a
> >while now, its purpose is to allow a user to upload a file, save it to
> >the server, resize it into a thumbnail, and save the thumbnail as
> >well. In my script all goes well until it comes to saving the images,
> >the script throws these errors:
> >
> >Warning: imagepng(): Unable to open
> >'/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15.png'
> >for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on
> >line 91
> >
> >Warning: imagepng(): Unable to open
> >'/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15t.png'
> >for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on
> >line 95
> >Picture "ffq" was added to our database! The following is what we have
> >generated and it is what others will see
> >
> >Here is the important part of the script, if more is needed i can post
> >it as well.
> >
> > if ($mime_type == 'jpeg') {
> > $new_image = imagecreatefromjpeg($_FILES['new_image']['tmp_name']);
> >//Create an image refrence
> > }
> > elseif ($mime_type == 'png') {
> > $new_image = imagecreatefrompng($_FILES['new_image']['tmp_name']);
> >//Create an image refrence
> > }
> > elseif ($mime_type == 'gif') {
> > $new_image = imagecreatefromgif($_FILES['new_image']['tmp_name']);
> >//Create an image refrence
> > }
> >
> > //Image Sizes
> > list($new_image_width, $new_image_height) =
> >getimagesize($_FILES['new_image']['tmp_name']);//Get img size
> > if ($new_image_width > $new_image_height) {//Get thumb size
> > $percent_image_size = (200 / $new_image_width);
> > }
> > elseif ($new_image_width < $new_image_height) {
> > $percent_image_size = (200 / $new_image_height);
> > }
> > else {
> > $percent_image_size = (200 / $new_image_height);
> > }
> > $new_thumb_width = ($percent_image_size * $new_image_width);
> > $new_thumb_height = ($percent_image_size * $new_image_height);
> >
> > $new_thumb_file = imagecreatetruecolor($new_image_width,
> > $new_image_height);
> > imagepng($new_image,
> >'/home/blacknut/public_html/picserv/picserv_mysql/pictures/' .
> >strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . '.png');
> >//Copy pic to user dir as pic_id.png
> >
> > $new_thumb_image = imagecreatetruecolor($new_thumb_width,
> >$new_thumb_height); // Create Thumb file
> > imagecopyresampled($new_thumb_image, $new_image, 0, 0, 0, 0,
> >$new_thumb_width, $new_thumb_height, $new_image_width,
> >$new_image_height); //Copy resized to new thumb file
> > imagepng($new_thumb_image,
> >'/home/blacknut/public_html/picserv/picserv_mysql/pictures/' .
> >strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . 't.png');
> >//Save image thumb
> >
> >I am very new to file/image manipulation in php so if you see any
> >errors, or unnecessary code please tell me. I'm not quit sure how
> >everything works, although I do have a theoretical picture of how it
> >does. Any comments will be appreciated.
> >
> >--nathan
> >
> >--
> >http://www.blacknute.com/
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
http://www.blacknute.com/
Navigation:
[Reply to this message]
|