is there anything wrong with this uploader?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    is there anything wrong with this uploader?

    I've made an uploader for my site and now I got a problem. first take a look at this code
    PHP Code:
    <?
    if(!$_POST['action'])
    {
    echo "<div class='line'>Select Image To Upload as Profile Pic</div>";
    print "<form action=\"?alt=3\" method=\"post\" enctype=\"multipart/form-data\">";
    print "<input class='inputAll' type='file' name='photo'>";
    print "<input type=\"hidden\" name=\"action\" value=\"upload\">";
    print "<input class='button' type=\"submit\" value=\"Upload\"></form>";
    }
    else
    {
    $photoname = $_FILES['photo']['name'];
    $phototmpname = $_FILES['photo']['tmp_name'];
    #$photo_size = getimagesize($phototmpname);
    list($width,$height) = getimagesize($phototmpname);
    $phototype = $_FILES['photo']['type'];
    $photosize = $_FILES['photo']['size'];
    $extens = file_extension($photoname);
    echo $phototmpname."|".$photoname."|".$phototype."|".$extens."|".$width."|".$height;
    $photo_rename = "$r.$extens";

        if(!is_uploaded_file($phototmpname))
        {
        $error.="An Error Occured During Upload this Picture.<br/>";
        }
        if($phototype != image_type_to_mime_type(IMAGETYPE_GIF) && $phototype != image_type_to_mime_type(IMAGETYPE_PNG) && $phototype != image_type_to_mime_type(IMAGETYPE_JPEG))
        {
        $error.="Supported formats: GIF, JPEG and PNG.<br/>";
        }

    if(empty($error))
    {
    if($phototype=='image/jpeg')
    {
    $im=ImageCreateFromJPEG($phototmpname);
    $tsrcs="./users/$nick/$photo_rename";
    $n_width=130;
    $n_height=150;
    $newimage=imagecreatetruecolor($n_width,$n_height);                 
    imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
    imageJPEG($newimage,$tsrcs,150);
    }
    elseif($phototype=='image/gif')
    {
    $im=imagecreatefromgif($phototmpname);
    $tsrcs="./users/$nick/$photo_rename";
    $n_width=130;
    $n_height=150;
    $newimage=imagecreatetruecolor($n_width,$n_height);                 
    imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
    imagegif($newimage,$tsrcs,150);
    }
    elseif($phototype=='image/png')
    {
    $im=imagecreatefrompng($phototmpname);
    $tsrcs="./users/$nick/$photo_rename";
    $n_width=130;
    $n_height=150;
    $newimage=imagecreatetruecolor($n_width,$n_height);                 
    imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
    $tmpPng =imagePNG($newimage,$tsrcs,100);
    }
    else
    {
    $im  = imagecreatetruecolor(150, 30);
    $bgc = imagecolorallocate($im, 255, 255, 255);
    $tc  = imagecolorallocate($im, 0, 0, 0);
    imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
    $tsrcs="./users/$nick/$photo_rename";
    $n_width=130;
    $n_height=150;
    imagestring($im, 1, 5, 5, 'Error loading ' . $phototmpname, $tc);
    $img = LoadPNG('bogus.image');
    imagepng($img);
    }
    imagedestroy($im);
    #--------------
    $dbpx = protect($photo_rename);
    $q = @mysql_query("update `users` set picture='$dbpx' where username='$nick';");
    if($q)
    {
        $_SESSION['success'] = "Successfully Uploaded.";
        $_SESSION['pic'] = "$dbpx";
        header('Location: profile.php?nocache='.$r.'');    
    }
    }
    else
    {
        echo "<div class='error'>Error Found</div>";
        echo $error;
        echo "<div class='box'><a class='normal' href='?alt=3'>Back</a>";
        echo "</div>";
    }
    }

    ?>
    and now tell me where is the wrong with this code?

    it gives me an error. that is
    HTML Code:
    Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in /home/chatabox/public_html/files/upload.tpl on line 15
    please give me a solution. where is the problem?

    #2
    the problem is
    PHP Code:
    $phototmpname $_FILES['photo']['tmp_name']; 
    is not responding i guess. and this kinds of uploader can consume high cpu uses.

    Comment


      #3
      so what should i do to solve the problem bro? This code works fine on localhost. but online it gives me this error. and how to solve the high cpu uses?

      Comment


        #4
        reg golbals need to be turn on
        Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
        Visit: WapMasterz Coming Back Soon!
        _______
        SCRIPTS FOR SALE BY SUBZERO
        Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
        FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
        _______
        Info & Tips
        php.net
        w3schools.com

        Comment


          #5
          if reg global is on, isnt there would be security problem?

          Comment


            #6
            for uploaders there is bro

            But if you wish to host a uploader that is better on cpu and safe to use

            then i will build one and charge you $15 for it...

            If no i can't help you.
            Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
            Visit: WapMasterz Coming Back Soon!
            _______
            SCRIPTS FOR SALE BY SUBZERO
            Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
            FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
            _______
            Info & Tips
            php.net
            w3schools.com

            Comment


              #7
              @asif, This code will work for you definitely if your server has no wrong. you should contact with your hosting provider to check this problem.

              Comment


                #8
                PHP Code:
                move_uploaded_file($phototmpname$photoname); 

                Comment

                Working...
                X