The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    387
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Gods Own Country
    cPanel Access Level:
    Root Administrator
    The permission of /tmp should be 777. You can run /scripts/securetmp as root and it will fix your problems with /tmp
     
  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