Activity Stream
48,167 MEMBERS
62772 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 10 of 10
  1.     
    #1
    Banned
    Website's:
    WarezRelease.org ThatHosting.co

    Default remote upload checks

    okay

    for local uploading i do checks like:

    PHP Code: 
            $name $_FILES['imagefile']['name']; //file name
            
    $type $_FILES['imagefile']['type']; // type of file
            
    $size $_FILES['imagefile']['size']; //size of the mage in bytes
            
    $imageKB round(($size 1024), 2); // bytes to KB 
            
    $imageMB round(($size 1048576), 2); // bytes to MB  
            
    $tmp_name $_FILES['imagefile']['tmp_name']; //temp file name and location
            
            /* // FILE SIZES  

    $file_gb = round(($filesize / 1073741824), 2); // bytes to GB  
    // PHP does funny thing for files larger than 2GB   */

            
    $ext substr($namestrrpos($name'.')); //grab file extension
            
            // Requirements
            
    $dimension getimagesize($tmp_name);
            
    $width $dimension[0]; // uploaded image width
            
    $height $dimension[1]; // uploaded image height 

            // get the extension of the file in a lower case format
             
    $ext strtolower($ext);

        if (
    in_array($type$allowed) && ($size <= $maxfileSize) && ( $width $maxWidth && $height $maxHeight )) {
            
    $name time().''.$ext//we will give an unique name, for example the time in unix time format 
            
    move_uploaded_file($tmp_name$uploadDir.'/'.$name); // upload the image, eventually i want to force the image on server to use my preferred file type

    as u see this if statement is doing the checks:

    PHP Code: 
        if (in_array($type$allowed) && ($size <= $maxfileSize) && ( $width $maxWidth && $height $maxHeight )) { 
    so can any1 tell me how/where to add for remote uploading, heres me code:

    PHP Code: 
        $urls explode("\n"$_POST['remoteimage']);
        
    $imgarray = array();

        foreach (
    $urls as $url) {

            
    $imgname basename($url);
            
    $localimg $uploadDir .'/'$imgname;
        
            
    $img file_get_contents($url);
            
            
    file_put_contents($localimg$img);
            
            
    $exten substr($urlstrrpos($url'.') + 1); // The "strrpos" approach to get the extension.

            
    $ch curl_init($url); // Get the filesize using curl
            
    curl_setopt($chCURLOPT_NOBODYtrue);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
            
    curl_setopt($chCURLOPT_HEADERtrue);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue); 
            
    $data curl_exec($ch);
            
    curl_close($ch);
            if (
    $data === false) {
                echo 
    'cURL failed';
                exit;
            }

            
    $remoteSize 'unknown';
            
    $status 'unknown';

            if (
    preg_match('/^HTTP\/1\.[01] (\d\d\d)/'$data$matches)) {
                
    $status = (int)$matches[1];
            }
            
            if (
    preg_match('/Content-Length: (\d+)/'$data$matches)) {
                
    $remoteSize = (int)$matches[1];
            }
            
    $imageKB round(($remoteSize 1024), 2); // bytes to KB 
            
    $imageMB round(($remoteSize 1048576), 2); // bytes to MB  
            
            
    $newname time().'.'.$exten// Got the file type, works ok, not ideal way but we need to check to see its valid t ype. really should use curl.
            
    $newImage $uploadDir .'/'.$newname;
            
    rename($localimg$newImage);  
        } 
    Chris2k Reviewed by Chris2k on . remote upload checks okay for local uploading i do checks like: $name = $_FILES; //file name $type = $_FILES; // type of file $size = $_FILES; //size of the mage in bytes $imageKB = round(($size / 1024), 2); // bytes to KB $imageMB = round(($size / 1048576), 2); // bytes to MB Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Here you go for the whole code:

    PHP Code: 
    $urls explode("\n"$_POST['remoteimage']);
    $imgarray = array();

    foreach (
    $urls as $url) {

    $imgname basename($url);
    $localimg $uploadDir .'/'$imgname;

    $allowed = array("jpg""jpeg""png""gif");
     
    $imgsizecheck getimagesize($url);
    $widthofimg $imgsizecheck[0];
    $heightofimg $imgsizecheck[1];

    $exten substr($imgnamestrrpos($imgname'.') + 1);

    if (
    in_array($exten$allowed) && ( $widthofimg $maxWidth && $heightofimg $maxHeight )) {  // Checks for width and extension of filetype
        
            
    $ch curl_init($url); // Get the filesize using curl
            
    curl_setopt($chCURLOPT_NOBODYtrue);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
            
    curl_setopt($chCURLOPT_HEADERtrue);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue); 
            
    $data curl_exec($ch);
            
    curl_close($ch);
            if (
    $data === false) {
                echo 
    'cURL failed';
                exit;
            }

            
    $remoteSize 'unknown';
            
    $status 'unknown';

            if (
    preg_match('/^HTTP\/1\.[01] (\d\d\d)/'$data$matches)) {
                
    $status = (int)$matches[1];
            }
            
            if (
    preg_match('/Content-Length: (\d+)/'$data$matches)) {
                
    $remoteSize = (int)$matches[1];
            }
            
    $imageKB round(($remoteSize 1024), 2); // bytes to KB 
            
    $imageMB round(($remoteSize 1048576), 2); // bytes to MB  
            
            
    if ($imageMB <= $maxfileSize) { // Checks for Filesize of the image
            
    file_put_contents($localimg$img);
            
    $newname time().'.'.$exten// Got the file type, works ok, not ideal way but we need to check to see its valid t ype. really should use curl.
            
    $newImage $uploadDir .'/'.$newname;
            
    rename($localimg$newImage);  
            }
    }


  4.     
    #3
    Banned
    Website's:
    WarezRelease.org ThatHosting.co
    Hi m8,

    i figured it a few mins after, but when i add this line:

    PHP Code: 
            if (in_array($exten$allowed) && ( $imageKB <= $maxfileSize ) && ( $width2 $maxWidth && $height2 $maxHeight )) { 
    above the: file_put_contents($localimg, $img);

    now i need to add an ending brace } , ive tried adding it after tha line above and the bottom line, heres my code:

    PHP Code: 
        elseif (isset($_POST['remoteUpload'])) {
        
        
    $urls explode("\n"$_POST['remoteimage']);
        
    $imgarray = array();

        foreach (
    $urls as $url) {

            
    $imgname basename($url);
            
    $localimg $uploadDir .'/'$imgname;
            
            
    // Requirements
            
    $pixels getimagesize($url); // Get image size in pixels for remote.
            
    $width2 $pixels[0];
            
    $height2 $pixels[1];

            
    $exten substr($urlstrrpos($url'.') + 1); // The "strrpos" approach to get the extension.
            
            
    $ch curl_init($url); // Get the filesize using curl
            
    curl_setopt($chCURLOPT_NOBODYtrue);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
            
    curl_setopt($chCURLOPT_HEADERtrue);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue); 
            
    $data curl_exec($ch);
            
    curl_close($ch);
            if (
    $data === false) {
                echo 
    'cURL failed';
                exit;
            }

            
    $remoteSize 'unknown';
            
    $status 'unknown';

            if (
    preg_match('/^HTTP\/1\.[01] (\d\d\d)/'$data$matches)) {
                
    $status = (int)$matches[1];
            }
            
            if (
    preg_match('/Content-Length: (\d+)/'$data$matches)) {
                
    $remoteSize = (int)$matches[1];
            }
            
    $imageKB round(($remoteSize 1024), 2); // bytes to KB 
            
    $imageMB round(($remoteSize 1048576), 2); // bytes to MB 

            
    $img file_get_contents($url);
            
            
    file_put_contents($localimg$img);

            
    $newname time().'.'.$exten
            
            
    $newImage $uploadDir .'/'.$newname;
            
            
    rename($localimg$newImage);  
        }          
        
        
    $param '[IMG]'.$siteURL.'/'.$uploadDir.'/'.$newname.'[/IMG]';
        
        
    $BBCode2 htmlspecialchars_decode($param);

            
    //Make a 90x90px thumbnail......
            
    $fileURL = ($uploadDir '/' $newname);
            
    //echo $fileURL;
            
            
    $newThumbImg imagecreatefromstring(file_get_contents($fileURL));
            
            
    $ratio $width2 $height2// calculate the ratio

            
    if ($ratio ) {
            
                
    $newW $thumbPixels;
                
    $newH $thumbPixels $ratio;
        } else {
                
                
    $newH $thumbPixels;
                
    $newW $thumbPixels $ratio;
        }
        
        
    //function for resize image.

        
    if ( function_exists 'imagecreatetruecolor' ) ) {

                
    $newImg imagecreatetruecolor($newW$newH);
        } else {

                die(
    "Error: Please make sure you have GD library ver 2+");
        }

        
    //the resizing is going on here!

        
    imagecopyresized($newImg$newThumbImg0000$newW$newH$width2$height2);
        
        
    $imageFileClean preg_replace("/Resource id #6/"""$newname);
        
    //finally, save the image
        
        
    ImageJpeg ($newImg$thumbDir $newname);
         
        
    ImageDestroy ($newImg);
        
    ImageDestroy ($newThumbImg);  
        
        echo 
    "<div align='center'><h1>You've just successfully uploaded <a href='$uploadDir/$newname'>$newname</a> with the following specifications ($imageKB KB / $imageMB MB and $width2 x $height2 pixels).</h1></div><br />
            
            <div align='center'><a href='
    $uploadDir/$newname' rel='lightbox'><img src='$uploadDir/$newname' width='95%' alt='$newname'></a></div><br />
            
            <table width='100%' style='margin: 0 auto;'>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> Direct Image Links</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Direct Image Link:</td>
            
            <td><input tabindex='1' value='
    $siteURL/$uploadDir/$newname' onclick='this.focus();this.select();' size='65' /></td><tr>
            
            <tr><td class='select_text' align='right'>HTML Link:</td>
            
            <td><input tabindex='2' value='"
    .htmlspecialchars_decode("<a href=\"$siteURL/$uploadDir/$newname\"><img src=\"$siteURL/$uploadDir/$newname\" border=\"0\"></a>")."' onclick='this.focus();this.select();' size='65'/></td></tr>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> BBCode (Forums)</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Code:</td> 
            
            <td><input tabindex='1' value='"
    .$BBCode2."' onclick='this.focus();this.select();' size='65' /></td></tr>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> Avatar/Profile Thumbnail</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Thumbnail (90px):</td>
            
            <td><input tabindex='1' value='
    $siteURL/$thumbDir$newname' onclick='this.focus();this.select();' size='65' /></td></tr>
            
            <tr><td class='select_text' align='right'>Your Custom Thumbnail:</td>
            
            <td><input tabindex='1' value='
    $siteURL/$customThumbDir/Custom_$newname' onclick='this.focus();this.select();' size='65' /></td></tr></table>";
        } 

  5.     
    #4
    Banned
    Website's:
    WarezRelease.org ThatHosting.co
    fixed, stupid me, obvious fix LOL..

    I was tryna use the types array tht i used for the local uploads, i needed a seperate array 4 just extensions... so heres my code:

    PHP Code: 
    elseif (isset($_POST['remoteUpload'])) {
        
        
    $urls explode("\n"$_POST['remoteimage']);
        
    $imgarray = array();

        foreach (
    $urls as $url) {

            
    $imgname basename($url);
            
    $localimg $uploadDir .'/'$imgname;
            
            
    // Requirements
            
    $pixels getimagesize($url); // Get image size in pixels for remote.
            
    $width2 $pixels[0];
            
    $height2 $pixels[1];

            
    $exten substr($urlstrrpos($url'.') + 1); // The "strrpos" approach to get the extension.
            
            
    $ch curl_init($url); // Get the filesize using curl
            
    curl_setopt($chCURLOPT_NOBODYtrue);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
            
    curl_setopt($chCURLOPT_HEADERtrue);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue); 
            
    $data curl_exec($ch);
            
    curl_close($ch);
            if (
    $data === false) {
                echo 
    'cURL failed';
                exit;
            }

            
    $remoteSize 'unknown';
            
    $status 'unknown';

            if (
    preg_match('/^HTTP\/1\.[01] (\d\d\d)/'$data$matches)) {
                
    $status = (int)$matches[1];
            }
            
            if (
    preg_match('/Content-Length: (\d+)/'$data$matches)) {
                
    $remoteSize = (int)$matches[1];
            }
            
    $imageKB round(($remoteSize 1024), 2); // bytes to KB 
            
    $imageMB round(($remoteSize 1048576), 2); // bytes to MB 

            
    $allowedext = array("jpg""jpeg""png""x-png""gif""bmp"); // only these for remote files, why we can't use the $allowed array is beyond me, -prolly a simple thing to do LOL.
            
            
    if (in_array($exten$allowedext) && ( $imageKB <= $maxfileSize ) && ( $width2 $maxWidth && $height2 $maxHeight )) {
            
    $img file_get_contents($url);
            
            
    file_put_contents($localimg$img);

            
    $newname time().'.'.$exten
            
            
    $newImage $uploadDir .'/'.$newname;
            
            
    rename($localimg$newImage);  
        }          
        
        
    $param '[IMG]'.$siteURL.'/'.$uploadDir.'/'.$newname.'[/IMG]';
        
        
    $BBCode2 htmlspecialchars_decode($param);

            
    //Make a 90x90px thumbnail......
            
    $fileURL = ($uploadDir '/' $newname);
            
    //echo $fileURL;
            
            
    $newThumbImg imagecreatefromstring(file_get_contents($fileURL));
            
            
    $ratio $width2 $height2// calculate the ratio

            
    if ($ratio ) {
            
                
    $newW $thumbPixels;
                
    $newH $thumbPixels $ratio;
        } else {
                
                
    $newH $thumbPixels;
                
    $newW $thumbPixels $ratio;
        }
        
        
    //function for resize image.

        
    if ( function_exists 'imagecreatetruecolor' ) ) {

                
    $newImg imagecreatetruecolor($newW$newH);
        } else {

                die(
    "Error: Please make sure you have GD library ver 2+");
        }

        
    //the resizing is going on here!

        
    imagecopyresized($newImg$newThumbImg0000$newW$newH$width2$height2);
        
        
    $imageFileClean preg_replace("/Resource id #6/"""$newname);
        
    //finally, save the image
        
        
    ImageJpeg ($newImg$thumbDir $newname);
         
        
    ImageDestroy ($newImg);
        
    ImageDestroy ($newThumbImg);  
        
        echo 
    "<div align='center'><h1>You've just successfully uploaded <a href='$uploadDir/$newname'>$newname</a> with the following specifications ($imageKB KB / $imageMB MB and $width2 x $height2 pixels).</h1></div><br />
            
            <div align='center'><a href='
    $uploadDir/$newname' rel='lightbox'><img src='$uploadDir/$newname' width='95%' alt='$newname'></a></div><br />
            
            <table width='100%' style='margin: 0 auto;'>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> Direct Image Links</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Direct Image Link:</td>
            
            <td><input tabindex='1' value='
    $siteURL/$uploadDir/$newname' onclick='this.focus();this.select();' size='65' /></td><tr>
            
            <tr><td class='select_text' align='right'>HTML Link:</td>
            
            <td><input tabindex='2' value='"
    .htmlspecialchars_decode("<a href=\"$siteURL/$uploadDir/$newname\"><img src=\"$siteURL/$uploadDir/$newname\" border=\"0\"></a>")."' onclick='this.focus();this.select();' size='65'/></td></tr>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> BBCode (Forums)</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Code:</td> 
            
            <td><input tabindex='1' value='"
    .$BBCode2."' onclick='this.focus();this.select();' size='65' /></td></tr>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> Avatar/Profile Thumbnail</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Thumbnail (90px):</td>
            
            <td><input tabindex='1' value='
    $siteURL/$thumbDir$newname' onclick='this.focus();this.select();' size='65' /></td></tr>
            
            <tr><td class='select_text' align='right'>Your Custom Thumbnail:</td>
            
            <td><input tabindex='1' value='
    $siteURL/$customThumbDir/Custom_$newname' onclick='this.focus();this.select();' size='65' /></td></tr></table>";
        }
        } 
    // < attempting a remote upload and all checks. 
    now i need to add an error, like i did for local uploading, which is:

    PHP Code: 
    else
            echo 
    "<p align='center' classs='select_text'>You have submitted an invalid extension/larger file size than we accept or the dimensions are too big.</p>"
    so i wanna add tht, wen i add it afteer the checks i get parse error.......

    any1 can help?

  6.     
    #5
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Try this:

    PHP Code: 
    elseif (isset($_POST['remoteUpload'])) {
        
        
    $urls explode("\n"$_POST['remoteimage']);
        
    $imgarray = array();

        foreach (
    $urls as $url) {

            
    $imgname basename($url);
            
    $localimg $uploadDir .'/'$imgname;
            
            
    // Requirements
            
    $pixels getimagesize($url); // Get image size in pixels for remote.
            
    $width2 $pixels[0];
            
    $height2 $pixels[1];

            
    $exten substr($urlstrrpos($url'.') + 1); // The "strrpos" approach to get the extension.
            
            
    $ch curl_init($url); // Get the filesize using curl
            
    curl_setopt($chCURLOPT_NOBODYtrue);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
            
    curl_setopt($chCURLOPT_HEADERtrue);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue); 
            
    $data curl_exec($ch);
            
    curl_close($ch);
            if (
    $data === false) {
                echo 
    'cURL failed';
                exit;
            }

            
    $remoteSize 'unknown';
            
    $status 'unknown';

            if (
    preg_match('/^HTTP\/1\.[01] (\d\d\d)/'$data$matches)) {
                
    $status = (int)$matches[1];
            }
            
            if (
    preg_match('/Content-Length: (\d+)/'$data$matches)) {
                
    $remoteSize = (int)$matches[1];
            }
            
    $imageKB round(($remoteSize 1024), 2); // bytes to KB 
            
    $imageMB round(($remoteSize 1048576), 2); // bytes to MB 

            
    $allowedext = array("jpg""jpeg""png""x-png""gif""bmp"); // only these for remote files, why we can't use the $allowed array is beyond me, -prolly a simple thing to do LOL.
            
            
    if (in_array($exten$allowedext) && ( $imageKB <= $maxfileSize ) && ( $width2 $maxWidth && $height2 $maxHeight )) {
            
    $img file_get_contents($url);
            
            
    file_put_contents($localimg$img);

            
    $newname time().'.'.$exten
            
            
    $newImage $uploadDir .'/'.$newname;
            
            
    rename($localimg$newImage);  
        
        
    $param '[IMG]'.$siteURL.'/'.$uploadDir.'/'.$newname.'[/IMG]';
        
        
    $BBCode2 htmlspecialchars_decode($param);

            
    //Make a 90x90px thumbnail......
            
    $fileURL = ($uploadDir '/' $newname);
            
    //echo $fileURL;
            
            
    $newThumbImg imagecreatefromstring(file_get_contents($fileURL));
            
            
    $ratio $width2 $height2// calculate the ratio

            
    if ($ratio ) {
            
                
    $newW $thumbPixels;
                
    $newH $thumbPixels $ratio;
        } else {
                
                
    $newH $thumbPixels;
                
    $newW $thumbPixels $ratio;
        }
        
        
    //function for resize image.

        
    if ( function_exists 'imagecreatetruecolor' ) ) {

                
    $newImg imagecreatetruecolor($newW$newH);
        } else {

                die(
    "Error: Please make sure you have GD library ver 2+");
        }

        
    //the resizing is going on here!

        
    imagecopyresized($newImg$newThumbImg0000$newW$newH$width2$height2);
        
        
    $imageFileClean preg_replace("/Resource id #6/"""$newname);
        
    //finally, save the image
        
        
    ImageJpeg ($newImg$thumbDir $newname);
         
        
    ImageDestroy ($newImg);
        
    ImageDestroy ($newThumbImg);  
        
        echo 
    "<div align='center'><h1>You've just successfully uploaded <a href='$uploadDir/$newname'>$newname</a> with the following specifications ($imageKB KB / $imageMB MB and $width2 x $height2 pixels).</h1></div><br />
            
            <div align='center'><a href='
    $uploadDir/$newname' rel='lightbox'><img src='$uploadDir/$newname' width='95%' alt='$newname'></a></div><br />
            
            <table width='100%' style='margin: 0 auto;'>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> Direct Image Links</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Direct Image Link:</td>
            
            <td><input tabindex='1' value='
    $siteURL/$uploadDir/$newname' onclick='this.focus();this.select();' size='65' /></td><tr>
            
            <tr><td class='select_text' align='right'>HTML Link:</td>
            
            <td><input tabindex='2' value='"
    .htmlspecialchars_decode("<a href=\"$siteURL/$uploadDir/$newname\"><img src=\"$siteURL/$uploadDir/$newname\" border=\"0\"></a>")."' onclick='this.focus();this.select();' size='65'/></td></tr>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> BBCode (Forums)</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Code:</td> 
            
            <td><input tabindex='1' value='"
    .$BBCode2."' onclick='this.focus();this.select();' size='65' /></td></tr>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> Avatar/Profile Thumbnail</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Thumbnail (90px):</td>
            
            <td><input tabindex='1' value='
    $siteURL/$thumbDir$newname' onclick='this.focus();this.select();' size='65' /></td></tr>
            
            <tr><td class='select_text' align='right'>Your Custom Thumbnail:</td>
            
            <td><input tabindex='1' value='
    $siteURL/$customThumbDir/Custom_$newname' onclick='this.focus();this.select();' size='65' /></td></tr></table>";
        }
        }   
    else
            echo 
    "<p align='center' classs='select_text'>You have submitted an invalid extension/larger file size than we accept or the dimensions are too big.</p>";      
        } 
    // < attempting a remote upload and all checks. 

  7.     
    #6
    Banned
    Website's:
    WarezRelease.org ThatHosting.co
    still getting parse error m8... it seems to be 2nd to last line, when im ending the other check statement .

  8.     
    #7
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    You might be including some file

    Check all the files included syntax for mistakes

    Edit: What line you getting error on?

    Edit again: try this naw:

    PHP Code: 
    elseif (isset($_POST['remoteUpload'])) {
        
        
    $urls explode("\n"$_POST['remoteimage']);
        
    $imgarray = array();

        foreach (
    $urls as $url) {

            
    $imgname basename($url);
            
    $localimg $uploadDir .'/'$imgname;
            
            
    // Requirements
            
    $pixels getimagesize($url); // Get image size in pixels for remote.
            
    $width2 $pixels[0];
            
    $height2 $pixels[1];

            
    $exten substr($urlstrrpos($url'.') + 1); // The "strrpos" approach to get the extension.
            
            
    $ch curl_init($url); // Get the filesize using curl
            
    curl_setopt($chCURLOPT_NOBODYtrue);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
            
    curl_setopt($chCURLOPT_HEADERtrue);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue); 
            
    $data curl_exec($ch);
            
    curl_close($ch);
            if (
    $data === false) {
                echo 
    'cURL failed';
                exit;
            }

            
    $remoteSize 'unknown';
            
    $status 'unknown';

            if (
    preg_match('/^HTTP\/1\.[01] (\d\d\d)/'$data$matches)) {
                
    $status = (int)$matches[1];
            }
            
            if (
    preg_match('/Content-Length: (\d+)/'$data$matches)) {
                
    $remoteSize = (int)$matches[1];
            }
            
    $imageKB round(($remoteSize 1024), 2); // bytes to KB 
            
    $imageMB round(($remoteSize 1048576), 2); // bytes to MB 

            
    $allowedext = array("jpg""jpeg""png""x-png""gif""bmp"); // only these for remote files, why we can't use the $allowed array is beyond me, -prolly a simple thing to do LOL.
            
            
    if (in_array($exten$allowedext) && ( $imageKB <= $maxfileSize ) && ( $width2 $maxWidth && $height2 $maxHeight )) {
            
    $img file_get_contents($url);
            
            
    file_put_contents($localimg$img);

            
    $newname time().'.'.$exten
            
            
    $newImage $uploadDir .'/'.$newname;
            
            
    rename($localimg$newImage);  
        
        
    $param '[IMG]'.$siteURL.'/'.$uploadDir.'/'.$newname.'[/IMG]';
        
        
    $BBCode2 htmlspecialchars_decode($param);

            
    //Make a 90x90px thumbnail......
            
    $fileURL = ($uploadDir '/' $newname);
            
    //echo $fileURL;
            
            
    $newThumbImg imagecreatefromstring(file_get_contents($fileURL));
            
            
    $ratio $width2 $height2// calculate the ratio

            
    if ($ratio ) {
            
                
    $newW $thumbPixels;
                
    $newH $thumbPixels $ratio;
        } else {
                
                
    $newH $thumbPixels;
                
    $newW $thumbPixels $ratio;
        }
        
        
    //function for resize image.

        
    if ( function_exists 'imagecreatetruecolor' ) ) {

                
    $newImg imagecreatetruecolor($newW$newH);
        } else {

                die(
    "Error: Please make sure you have GD library ver 2+");
        }

        
    //the resizing is going on here!

        
    imagecopyresized($newImg$newThumbImg0000$newW$newH$width2$height2);
        
        
    $imageFileClean preg_replace("/Resource id #6/"""$newname);
        
    //finally, save the image
        
        
    ImageJpeg ($newImg$thumbDir $newname);
         
        
    ImageDestroy ($newImg);
        
    ImageDestroy ($newThumbImg);  
        
        echo 
    "<div align='center'><h1>You've just successfully uploaded <a href='$uploadDir/$newname'>$newname</a> with the following specifications ($imageKB KB / $imageMB MB and $width2 x $height2 pixels).</h1></div><br />
            
            <div align='center'><a href='
    $uploadDir/$newname' rel='lightbox'><img src='$uploadDir/$newname' width='95%' alt='$newname'></a></div><br />
            
            <table width='100%' style='margin: 0 auto;'>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> Direct Image Links</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Direct Image Link:</td>
            
            <td><input tabindex='1' value='
    $siteURL/$uploadDir/$newname' onclick='this.focus();this.select();' size='65' /></td><tr>
            
            <tr><td class='select_text' align='right'>HTML Link:</td>
            
            <td><input tabindex='2' value='"
    .htmlspecialchars_decode("<a href=\"$siteURL/$uploadDir/$newname\"><img src=\"$siteURL/$uploadDir/$newname\" border=\"0\"></a>")."' onclick='this.focus();this.select();' size='65'/></td></tr>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> BBCode (Forums)</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Code:</td> 
            
            <td><input tabindex='1' value='"
    .$BBCode2."' onclick='this.focus();this.select();' size='65' /></td></tr>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> Avatar/Profile Thumbnail</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Thumbnail (90px):</td>
            
            <td><input tabindex='1' value='
    $siteURL/$thumbDir$newname' onclick='this.focus();this.select();' size='65' /></td></tr>
            
            <tr><td class='select_text' align='right'>Your Custom Thumbnail:</td>
            
            <td><input tabindex='1' value='
    $siteURL/$customThumbDir/Custom_$newname' onclick='this.focus();this.select();' size='65' /></td></tr></table>";
        }
    else
         echo 
    "<p align='center' classs='select_text'>You have submitted an invalid extension/larger file size than we accept or the dimensions are too big.</p>";      
        }   
        } 
    // < attempting a remote upload and all checks. 

  9.     
    #8
    Banned
    Website's:
    WarezRelease.org ThatHosting.co
    Line 334 which wud be the bit wheere it says else

  10.     
    #9
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    PHP Code: 
    elseif (isset($_POST['remoteUpload'])) {
        
        
    $urls explode("\n"$_POST['remoteimage']);
        
    $imgarray = array();

        foreach (
    $urls as $url) {

            
    $imgname basename($url);
            
    $localimg $uploadDir .'/'$imgname;
            
            
    // Requirements
            
    $pixels getimagesize($url); // Get image size in pixels for remote.
            
    $width2 $pixels[0];
            
    $height2 $pixels[1];

            
    $exten substr($urlstrrpos($url'.') + 1); // The "strrpos" approach to get the extension.
            
            
    $ch curl_init($url); // Get the filesize using curl
            
    curl_setopt($chCURLOPT_NOBODYtrue);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
            
    curl_setopt($chCURLOPT_HEADERtrue);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue); 
            
    $data curl_exec($ch);
            
    curl_close($ch);
            if (
    $data === false) {
                echo 
    'cURL failed';
                exit;
            }

            
    $remoteSize 'unknown';
            
    $status 'unknown';

            if (
    preg_match('/^HTTP\/1\.[01] (\d\d\d)/'$data$matches)) {
                
    $status = (int)$matches[1];
            }
            
            if (
    preg_match('/Content-Length: (\d+)/'$data$matches)) {
                
    $remoteSize = (int)$matches[1];
            }
            
    $imageKB round(($remoteSize 1024), 2); // bytes to KB 
            
    $imageMB round(($remoteSize 1048576), 2); // bytes to MB 

            
    $allowedext = array("jpg""jpeg""png""x-png""gif""bmp"); // only these for remote files, why we can't use the $allowed array is beyond me, -prolly a simple thing to do LOL.
            
            
    if (in_array($exten$allowedext) && ( $imageKB <= $maxfileSize ) && ( $width2 $maxWidth && $height2 $maxHeight )) {
            
    $img file_get_contents($url);
            
            
    file_put_contents($localimg$img);

            
    $newname time().'.'.$exten
            
            
    $newImage $uploadDir .'/'.$newname;
            
            
    rename($localimg$newImage);  
        
        
    $param '[IMG]'.$siteURL.'/'.$uploadDir.'/'.$newname.'[/IMG]';
        
        
    $BBCode2 htmlspecialchars_decode($param);

            
    //Make a 90x90px thumbnail......
            
    $fileURL = ($uploadDir '/' $newname);
            
    //echo $fileURL;
            
            
    $newThumbImg imagecreatefromstring(file_get_contents($fileURL));
            
            
    $ratio $width2 $height2// calculate the ratio

            
    if ($ratio ) {
            
                
    $newW $thumbPixels;
                
    $newH $thumbPixels $ratio;
        } else {
                
                
    $newH $thumbPixels;
                
    $newW $thumbPixels $ratio;
        }
        
        
    //function for resize image.

        
    if ( function_exists 'imagecreatetruecolor' ) ) {

                
    $newImg imagecreatetruecolor($newW$newH);
        } else {

                die(
    "Error: Please make sure you have GD library ver 2+");
        }

        
    //the resizing is going on here!

        
    imagecopyresized($newImg$newThumbImg0000$newW$newH$width2$height2);
        
        
    $imageFileClean preg_replace("/Resource id #6/"""$newname);
        
    //finally, save the image
        
        
    ImageJpeg ($newImg$thumbDir $newname);
         
        
    ImageDestroy ($newImg);
        
    ImageDestroy ($newThumbImg);  
        
        echo 
    "<div align='center'><h1>You've just successfully uploaded <a href='$uploadDir/$newname'>$newname</a> with the following specifications ($imageKB KB / $imageMB MB and $width2 x $height2 pixels).</h1></div><br />
            
            <div align='center'><a href='
    $uploadDir/$newname' rel='lightbox'><img src='$uploadDir/$newname' width='95%' alt='$newname'></a></div><br />
            
            <table width='100%' style='margin: 0 auto;'>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> Direct Image Links</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Direct Image Link:</td>
            
            <td><input tabindex='1' value='
    $siteURL/$uploadDir/$newname' onclick='this.focus();this.select();' size='65' /></td><tr>
            
            <tr><td class='select_text' align='right'>HTML Link:</td>
            
            <td><input tabindex='2' value='"
    .htmlspecialchars_decode("<a href=\"$siteURL/$uploadDir/$newname\"><img src=\"$siteURL/$uploadDir/$newname\" border=\"0\"></a>")."' onclick='this.focus();this.select();' size='65'/></td></tr>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> BBCode (Forums)</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Code:</td> 
            
            <td><input tabindex='1' value='"
    .$BBCode2."' onclick='this.focus();this.select();' size='65' /></td></tr>
            
            <tr><td><h1><img src='site_images/IMGHost.png'> Avatar/Profile Thumbnail</h1></td></tr>
            
            <tr><td class='select_text' align='right'>Thumbnail (90px):</td>
            
            <td><input tabindex='1' value='
    $siteURL/$thumbDir$newname' onclick='this.focus();this.select();' size='65' /></td></tr>
            
            <tr><td class='select_text' align='right'>Your Custom Thumbnail:</td>
            
            <td><input tabindex='1' value='
    $siteURL/$customThumbDir/Custom_$newname' onclick='this.focus();this.select();' size='65' /></td></tr></table>";
        }
    else {
         echo 
    "<p align='center' classs='select_text'>You have submitted an invalid extension/larger file size than we accept or the dimensions are too big.</p>";      
    }    
    }   
    // < attempting a remote upload and all checks. 

  11.     
    #10
    Banned
    Website's:
    WarezRelease.org ThatHosting.co
    That works gr8, ty...

    ps. i forgot, did i donate to u? if not pm me ur PP id i can send a few $$.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Remote Upload VS FTP VS Z-o-o-m
    By simoestcoool in forum Polling Plaza
    Replies: 17
    Last Post: 29th Aug 2012, 01:00 PM
  2. Replies: 3
    Last Post: 28th Apr 2011, 12:28 PM
  3. Replies: 10
    Last Post: 27th Mar 2011, 05:06 AM
  4. HF remote upload
    By tut2tut in forum Technical Help Desk Support
    Replies: 8
    Last Post: 1st Mar 2011, 07:52 PM
  5. Replies: 7
    Last Post: 11th Jun 2010, 04:41 AM

Tags for this Thread

BE SOCIAL