TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-11-2008, 06:15 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default Uploading problem

Hi, why does this exception get thrown?

PHP Code:
if(!move_uploaded_file($_FILES[$this->form_inputName]['tmp_name'], $this->image_tmpPath $this->file_name))
        {
                    
            throw new 
Exception('An error occured when uploading your file.');
                    
        } 
I mean, am I doing something wrong? Or is it just my variables that probably isn't correct?

Edit:
Got this now:

Code:
Warning: move_uploaded_file(images/2/tmp/23aede79f5b4c7aa2a97d7af38023893.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\test\Upload.php on line 142

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\phpABF.tmp' to 'images/2/tmp/23aede79f5b4c7aa2a97d7af38023893.jpg' in C:\wamp\www\test\Upload.php on line 142
__________________
Tanax is offline  
Reply With Quote
Old 11-11-2008, 07:16 PM   #2 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Nevermind! I solved that. Now it's just the thumbnail part that doesn't work:

php Code:
private function createThumb()
    {
       
        switch($_FILES[$this->form_inputName]['type'])
        {
           
            case 'image/jpeg':
               
                $srcimage = imagecreatefromjpeg($this->image_bigPath . $this->file_name);
                break;

            case 'image/gif':

                $srcimage = imagecreatefromgif($this->image_bigPath . $this->file_name);
                break;

            case 'image/png':
               
                $srcimage = imagecreatefrompng($this->image_bigPath . $this->file_name);
                break;
           
            default:
               
                $srcimage = imagecreatefromjpeg($this->image_bigPath . $this->file_name);
               
        }
       

        $srcimagex = imagesx($srcimage);
        $srcimagey = imagesy($srcimage);
        if($srcimagex > $this->thumb_width || $srcimagey > $this->thumb_height)
        {

            if($srcimagex > $srcimagey) $ratio = $this->thumb_width / $srcimagex;
            elseif($srcimagex < $srcimagey) $ratio = $this->thumb_height / $srcimagex;
            else $ratio = (($this->thumb_width + $this->thumb_height) / 2) / $srcimagey;

            $thumbwidth = $srcimagex * $ratio;
            $thumbheight = $srcimagey * $ratio;
           
            $thumbnail = imagecreatetruecolor($thumbwidth, $thumbheight);
            imagecopyresampled($thumbnail, $srcimage, 0, 0, 0, 0, $thumbwidth, $thumbheight, $srcimagex, $srcimagey);
            $success = imagejpeg($thumbnail, $this->image_thuPath . $this->file_name, 75);
           
            if($success)
            {
               
                $this->thumb_creation = 1;
                unlink($this->image_thuPath . $this->file_name);
               
            }
           
            else throw new Exception('Thumbnail creation did not work.');         

        }
       
    }
__________________

Last edited by Tanax : 11-11-2008 at 07:48 PM.
Tanax is offline  
Reply With Quote
Old 11-12-2008, 09:02 AM   #3 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Nevermind again xD I solved it thanks to Eyedentify
__________________
Tanax is offline  
Reply With Quote
The Following User Says Thank You to Tanax For This Useful Post:
EyeDentify (11-12-2008)
Old 11-12-2008, 10:58 AM   #4 (permalink)
The Acquainted
 
EyeDentify's Avatar
 
Join Date: Nov 2007
Location: Sweden
Posts: 106
Thanks: 13
EyeDentify is on a distinguished road
Default

@Tanax.

Iīm just glad i could help.

I know how it is, Sometimes you donīt see your misstakes clearly if you have starred at a code snippet for a while. Then itīs good to have someone else to have a look.

And to clearify, the error seems to have been the unlink() functions strategic placement :) it caused the Thumbnail to get deleted. :)
__________________
Of course the whole point of a doomsday machine, would have been lost if you keep it a secret.
EyeDentify is offline  
Reply With Quote
The Following User Says Thank You to EyeDentify For This Useful Post:
Tanax (11-12-2008)
Old 11-12-2008, 11:08 AM   #5 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Hehe yea, I know xD It got deleted right after it was created :P I suck >.< hehe
__________________
Tanax is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:14 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design