Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2005, 03:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default Warning: imagejpeg(): Unable to open

HELP!!! Please
I cannot figure out what is causing this, obviously. I have a file that I upload and rename, this works fine but when I try to duplicate it and make a thumbnail is where the problem lies, from what I've read it seems like a permissions issue. I have double checked and the images_products_thumbs is set to full permissions. Is this error being caused because it's trying to write to where the php file is stored?


Warning: imagejpeg(): Unable to open 'c:/sites/sitefolder/images_products_thumbs/prod_tn_6.jpg'
for writing in c:sites\components\sitefolder\edit_images.php on line 58

    $image_tempname = $_FILES['image_filename']['name'];
    $ImageDir = "c:sites/sitefolder/images_products/";
    $ImageName = $ImageDir . $image_tempname;

if (move_uploaded_file($_FILES['image_filename']['tmp_name'], $ImageName)) {
        list($width, $height, $type, $attr) = getimagesize($ImageName);

        switch($type) {
            case 2:
                $ext = ".jpg";
                break;
            case 3:
                $ext = ".png";
                break;
            default:
                $vProd_Image = False;
                $strError = "The image you uploaded was not in the correct format. The only formats acceptable are JPG or PNG.";
                unlink($ImageName);
        }

        echo $ext . "--ext<BR><BR>";

        if (!isset($strError)) {
            $filenameforDB = "prod_" . $strModifyID . $ext;
            $newfilename = $ImageDir . "prod_" . $strModifyID . $ext;
            rename($ImageName, $newfilename);
            $ImageThumb = "c:sites/sitefolder/images_products_thumbs/";
            $newthumbname = $ImageThumb . "prod_tn_" . $strModifyID . $ext;

            $newThmb_W = $width * 0.20;
            $newThmb_H = $height * 0.20;

            switch($type) {
            case 2:
                $src_img=imagecreatefromjpeg($newfilename);
                echo "--creating from jpeg<BR>";
                break;
            case 3:
                $src_img=imagecreatefrompng($newfilename);
                echo "--creating from png<BR>";
                break;
            }

            $dst_img=ImageCreateTrueColor($newThmb_W,$newThmb_ H);
            imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $newThmb_W, $newThmb_H, $width, $height);

            switch($type) {
            case 2:
                imagejpeg($dst_img, $newthumbname);
                break;
            case 3:
                imagepng($dst_img, $newthumbname);
                break;
            }

            imagedestroy($dst_img);
            imagedestroy($src_img);
        }

Thanks
Mike
__________________
Peace
Mike
http://www.eclecticpixel.com
 
Old July 12th, 2005, 03:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

never mind...i can't type.





Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ Unable to open include file. Allen_T 08 C++ Programming 4 July 7th, 2016 01:43 PM
Unable to open Tomcat console on IE lakshmip Apache Tomcat 0 December 4th, 2007 01:18 AM
Report Manager - unable to open Reshmacb BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 October 23rd, 2007 02:22 AM
Unable to open ProjectTimeTracker DB cancer2006 BOOK: Beginning VB.NET Databases 2 October 24th, 2006 03:53 PM
PHP Warning: PHP Startup: Unable to load dynamic l surendran Beginning PHP 1 May 29th, 2006 08:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.