Warning: imagejpeg()

jm1968a 01 Mar, 2012
Hi All,

I'm having a small issue that I was hoping that you can help with. I have an upload form and want to allow users to up[load any size file, then modify the size and store it in a particular folder and then delete the temp file after.

The problem us that I keep getting an error with the $target path and file.

[quote]Warning: imagejpeg() [function.imagejpeg]: Unable to open 'http://www.XXXXXX.com/images/600px/20120229203233_P1060186.JPG' for writing: No such file or directory in /home/XXXXXX/public_html/administrator/components/com_chronoforms/form_actions/custom_code/cfaction_custom_code.php(14) : eval()'d code on line 39[/quote]

When I inspecting the folder, the $source is OK, but nothing made it into the $target folder

Any ideas - Jason

		<?php
        
        defined('_JEXEC') or die;
        
        ////////////////////////
        $name 	= $form->data['file_id'];
        $source	= "http://www.xxxxxx.com/images/temp/$name";
        $target	= "http://www.xxxxxx.com/images/600px/$name";
        $maxh	= 600;
        $maxw	= 300;
        
        // get etention of source file
        $kaboom	= explode(".", $source);
        $file_ext	= $kaboom[1];
        
        changeimagesize($source, $target, $maxw, $maxh, $file_ext, $name);
        
        function changeimagesize($source, $target, $maxw, $maxh, $file_ext, $name){
            list($w_orig, $h_orig) = getimagesize($source);
            $scale_ratio=$w_orig / $h_orig;
            if (($maxw / $maxh) > $scale_ratio){	
                $maxw = $maxh * $scale_ratio;
            } else {
                $maxh = $maxw /  $scale_ratio;
            }
            $img = "";
            $file_ext	= strtolower($file_ext);
            if($file_ext == "png"){
                $img = imagecreatefrompng($source);
            } else if ($file_ext == "gif"){
                $img = imagecreatefromgif($source);
            } else {
                $img = imagecreatefromjpeg($source);
            }
            
            $tci = imagecreatetruecolor($maxw, $maxh);
            
            imagecopyresampled($tci, $img, 0, 0, 0, 0, $maxw, $maxh, $w_orig, $h_orig);		
            imagejpeg($tci, $target, 75);
        ?><img src="<?php echo $source ?>" height="<?php echo $maxh ?>" width="<?php echo $maxw ?>" />	
            <?php }
        echo $name;
        ?>
GreyHead 01 Mar, 2012
Hi Jason,

How are you uploading the file?

Have you tried the Image Resizer action?

Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here. Note: if you are using the Easy Wizard you may need to switch to the Advanced Wizard to do this; if you want to continue to use the Easy Wizard please make a copy of your form first and add the Debugger action to the copy.

Bob
jm1968a 20 Apr, 2012
Hi Bob,

Sorry for the delay in getting back to you.

I have changed the for a suggested, and it works perfectly.

I have one question that I hope you can help with. After the form has been submitted, I wish to reload the previous page. (URL) Can you point me in the right direction on how to do this?

Jason
GreyHead 20 Apr, 2012
Hi Jason,

Use a ReDirect User action with the form URL in it as the last action in the On Submit event.

Bob
This topic is locked and no more replies can be posted.