1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Php GD help

Discussion in 'PHP' started by Liberation, Jan 22, 2007.

  1. #1
    Hi there

    Im in need of some help with a script that i recently bought and am having a little trouble with one perticular part of it. The script is 'The Grand Tutorial' ( www.thegrandtutorial.com ) and its all installed but one problem i have is when adding a tutorial via Admin CP there is a option that you can upload a image to go at the top of that perticular page. When uploaded, i get an error message saying:


    Warning: imagecreatefromjpeg(/home/USERNAME/public_html/images/upload/steps/step_4ff9c22298c7.jpg): failed to open stream: No such file or directory in /home/tutorlov/public_html/admin/functions.php on line 584

    Warning: imagesx(): supplied argument is not a valid Image resource in /home/tutorlov/public_html/admin/functions.php on line 591

    Warning: imagesy(): supplied argument is not a valid Image resource in /home/tutorlov/public_html/admin/functions.php on line 592


    On those perticular lines i have:

    584- if($ext == 'jpg' || $ext == 'jpeg'){
    591- Nothing there
    592- $xw = imagesx($img);

    Im really hoping that somebody can help me in sorting this problem out as soon as possible.
    If any more infomation is needed ( such as the whole code ) please either PM or post below.

    Thanks very much
     
    Liberation, Jan 22, 2007 IP
  2. StanUK

    StanUK Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What file type are you trying to upload?

    Also, do you have the permissions set correctly to allow files to be uploaded to that directory?
     
    StanUK, Jan 22, 2007 IP
  3. Liberation

    Liberation Peon

    Messages:
    739
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Stan,

    I have set the permissions to '777' so it should work. And im trying to upload a either a .png file or a .jpg file.

    Thanks
     
    Liberation, Jan 23, 2007 IP
  4. libneiz

    libneiz Peon

    Messages:
    9
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    can you see this file in the tree: /home/USERNAME/public_html/images/upload/steps/step_4ff9c22298c7.jpg ?
     
    libneiz, Jan 23, 2007 IP
  5. Liberation

    Liberation Peon

    Messages:
    739
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Liberation, Jan 23, 2007 IP
  6. Liberation

    Liberation Peon

    Messages:
    739
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Any other help, as if possible id like this sorted hopefully as soon as i can....
     
    Liberation, Jan 23, 2007 IP
  7. MattD

    MattD Peon

    Messages:
    161
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I know this sounds stupid, but you have replaced "USERNAME" with the right directory name right?
     
    MattD, Jan 23, 2007 IP
  8. Liberation

    Liberation Peon

    Messages:
    739
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I havnt changed that. As that would most proably just be there to show the buyer of the script that their Username would go there...?

    Im proably wrong. But ive looked for that, and cannot find where i change it anywhere
     
    Liberation, Jan 23, 2007 IP
  9. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #9
    Seems like a config.php file or something needs to be edited to me.
     
    noppid, Jan 23, 2007 IP
  10. Liberation

    Liberation Peon

    Messages:
    739
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #10
    In the Admin Folder there is no Config.php file
     
    Liberation, Jan 23, 2007 IP
  11. MattD

    MattD Peon

    Messages:
    161
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Without knowing more about the script, it sounds to me like you need to change that USERNAME to a real value - i.e. for a directory that exists and this script has access to.

    If you could paste a lines 580 to 584 from /home/tutorlov/public_html/admin/functions.php, it would be easier to see what is going on.
     
    MattD, Jan 23, 2007 IP
  12. Liberation

    Liberation Peon

    Messages:
    739
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Here are some lines of the code as you requested:

    582 - function imgsizemod($image = '', $ext = ''){
    584 -if($ext == 'jpg' || $ext == 'jpeg'){
    585 - $img = imagecreatefromjpeg($image);
    586 - } elseif($ext == 'png'){
    587 - $img = imagecreatefrompng($image);
    588 - } else {
    589 - return basename($image);


    Any more request for the code, please say
    Thanks
     
    Liberation, Jan 24, 2007 IP
  13. MattD

    MattD Peon

    Messages:
    161
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Ok - can you find out where the variable $image is assigned a value, and paste that here too.
     
    MattD, Jan 24, 2007 IP
  14. Liberation

    Liberation Peon

    Messages:
    739
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #14
    That is:

    function imgsizemod($image = '', $ext = ''){
     
    Liberation, Jan 24, 2007 IP
  15. picouli

    picouli Peon

    Messages:
    760
    Likes Received:
    89
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Nope, that's where the imgsizemod function is declared - you should look for 'imgsizemod(' in your scripts (not in the file where you found the line above) and check the first param
     
    picouli, Jan 24, 2007 IP
  16. Liberation

    Liberation Peon

    Messages:
    739
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Sorry

    This should be right:

    $thumb = $this->imgsizemod($config['image_dir'].'/steps/'.$nflm, $ext);
     
    Liberation, Jan 24, 2007 IP
  17. picouli

    picouli Peon

    Messages:
    760
    Likes Received:
    89
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Now we are getting somewhere - now you should look for a file called 'config.inc.php' or something like that (it should be included ore required at the beginning of each script) and check what's the value for $config['image_dir'] - and possibly change it to an existing (and writable) directory on your server
     
    picouli, Jan 24, 2007 IP
  18. Liberation

    Liberation Peon

    Messages:
    739
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Hi there

    I cannot find the above file of 'config.inc.php' anywhere on the script for some reason.
     
    Liberation, Jan 24, 2007 IP
  19. Liberation

    Liberation Peon

    Messages:
    739
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #19
    I was wondering, looking around would this be of any help:

    global $config;
    @move_uploaded_file($_FILES['s_img']['tmp_name'], $config['image_dir'].'/steps/'.$nflm);

    $insert['s_img'] = $nflm;
    $thumb = $this->imgsizemod($config['image_dir'].'/steps/'.$nflm, $ext);
    $insert['s_thumb'] = $thumb;
     
    Liberation, Jan 24, 2007 IP
  20. MattD

    MattD Peon

    Messages:
    161
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Somewhere there will be a line that starts:

    "$config['image_dir']=..."

    See if you can find that somewhere - it might be in a different PHP file though. If you can find that then paste it here we might get a bit further :)
     
    MattD, Jan 24, 2007 IP