Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

trying to upload images - /tmp folder permissions

Discussion in 'General Discussion' started by liviuf, Mar 18, 2013.

  1. liviuf

    liviuf Member

    Joined:
    Mar 18, 2013
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    First of all hi!
    I know there are many threads about this but I need help...
    On my website I have an admin section where I post some text to an database and upload one image to the server...
    Here's the problem:
    PHP:
    Warningmove_upload_file(evenimente/images/test.jpg):failed to open streamPermission denied in file/path on line ...
    Warningmove_upload_fileUnable to move '/tmp/phpsTjYQC' to 'evenimente/images/test.jpg' in file/path on line ...
    My code
    PHP:
    $file=$_FILES['image']['tmp_name'];
    $imageaddslashes(file_get_contents($_FILES['image']['tmp_name']));
    $image_nameaddslashes($_FILES['image']['name']);
    $sizes = array();
    $sizes['100'] = 100;
    list(,,
    $type) = getimagesize($_FILES['image']['tmp_name']);
    $type image_type_to_extension($type);
    move_uploaded_file($_FILES['image']['tmp_name'], 'evenimente/images/'.$prefix.$type);
    $t 'imagecreatefrom'.$type;
    $t str_replace('.','',$t);
    $img $t('evenimente/images/'.$prefix.$type);
    foreach(
    $sizes as $k=>$v)
                {

                        
    $width imagesx$img );
                
    $height imagesy$img );
                
    $new_width $v;
                
    $new_height '147';
                            
    $tmp_img imagecreatetruecolor$new_width$new_height );
                
    imagealphablending$tmp_imgfalse );
                
    imagesavealpha$tmp_imgtrue );
                
    imagecopyresampled$tmp_img$img0000$new_width$new_height$width$height );

                
    $c 'image'.$type;
                
    $c str_replace('.','',$c);
                
    $c$tmp_img'evenimente/images/th/'.$prefix.$type );
                }                                        
    The code was made in case i needed to make more thumbnails of the uploaded image.
    The permission on tmp folder 755

    Cheers!

    If you need any info I'm here :)
    For the record I'm logged in as an database user, not root...
    The code works on localhost using wamp server
     
    #1 liviuf, Mar 18, 2013
    Last edited: Mar 18, 2013
  2. NixTree

    NixTree Well-Known Member

    Joined:
    Aug 19, 2010
    Messages:
    405
    Likes Received:
    3
    Trophy Points:
    143
    Location:
    Gods Own Country
    cPanel Access Level:
    Root Administrator
    Twitter:
    The permission of /tmp should be 777. You can run /scripts/securetmp as root and it will fix your problems with /tmp
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. liviuf

    liviuf Member

    Joined:
    Mar 18, 2013
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    changed the permission to 777, still getting those errors...
     
  4. liviuf

    liviuf Member

    Joined:
    Mar 18, 2013
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    ok..solved
    I'm just dumb thx for the help xD
     
  5. liviuf

    liviuf Member

    Joined:
    Mar 18, 2013
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Now I'm getting this
    PHP:
    fatal errorallowed memory size of bytes x exhausted (tried to allocate y bytes)
    :mad::mad::mad::mad::mad:
     
  6. liviuf

    liviuf Member

    Joined:
    Mar 18, 2013
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    solved that to...

    PHP:
    ini_set('memory_limit''-1');
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice