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

Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18
  1.     
    #11
    Member
    hey man.. thanks for your time!

    I have written my own bash script that does some automation. I need a script, php or bash one, which uploads image to your host and returns bbcode with 550px thumb. The thing is that I know bash a bit, but I have absolutely zero knowledge with php.

    thanks again

    cheers

  2.   Sponsored Links

  3.     
    #12
    Member
    Website's:
    ImageZilla.net
    Not a problem. So do you want remote upload or regular upload? or both?

  4.     
    #13
    Member
    Well, whichever is easier for you to code. I have no special request there, but of course both options would be nice, the more the merrier

    If you insist that I choose one, it would be remote upload, I guess

    cheers

  5.     
    #14
    Member
    Website's:
    ImageZilla.net
    I'll get both going

  6.     
    #15
    Member
    thanks once more

  7.     
    #16
    Member
    Website's:
    ImageZilla.net
    Here's a script tested working on linux. I'm not sure about windows but I dont think you should have any problems. One function is for urls and the other function is for files. If you run your own php scripts should be able to just drop the functions in. Let me know if there any problems.

    UPDATED: V2
    Code: 
    <?
    
    function imagezilla_url($img_url){
        $thsize = '300'; //valid sizes are 150, 250,300,450,550 pixels
        $img_url = urlencode($img_url);
        $url = "http://imagezilla.net/firefoxremote.php?thumbsize=$thsize&url=$img_url";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, trim($url));
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        preg_match("/(http:\/\/(?:\w+\.){0,1}imagezilla\.net\/thumbs\/.*?)'/i",$result,$tn);
        preg_match("/(http:\/\/(?:\w+\.){0,1}imagezilla\.net\/images\/.*?)'/i",$result,$lp);
        $link_code = '';
        $tn = $tn[1];
        $lp = $lp[1];
        $lp = str_replace('/images/','/show/', $lp);
        $link_code .= "<a href='$lp'><img src='$tn'".'></a>'."\n"; //html
        $link_code .= '[img]'.$tn.'[/img]'."\n"; //bbcode
        return $link_code; //first line contains html code, second line contains bb code. Comment out the code you dont want.
    } 
    
    function imagezilla_file($img_filename){
        $thsize = '400'; // thumbnail size: must be between 150px and 550px. Default is 400px
        $adult = 1; //defaults to adult images, set it to 0 if you are uploading non-adult images
        $key = "7t7ung19lktujxqddsva7mgtnoi7u1i5";
        $post = array('file'=> "@$img_filename",'apikey' => "$key",'thumbsize' => "$thsize",'adult'=>"$adult");
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "http://imagezilla.net/api.php");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        preg_match('/<thumbnail>(.*?)<\/thumbnail>/i',$result,$tn);
        preg_match('/<largepic>(.*?)<\/largepic>/i',$result,$lp);
        $link_code = '';
        $tn = $tn[1];
        $lp = $lp[1];
        $link_code .= "<a href='$lp'><img src='$tn'".'></a>'."\n"; //html
        $link_code .= '[img]'.$tn.'[/img]'."\n"; //bbcode
        return $link_code; //first line contains html code, second line contains bb code. Comment out the code you dont want.
    } 
    $image = $argv[1];
    if (strpos($image, 'http://') === 0) {
        echo imagezilla_url($image);
    } else {
        echo imagezilla_file($image);
    }
    ?>

  8.     
    #17
    Member
    You, sir are AWESOME

    Works like a charm, thanks a lot!

    If anyone else needs this script, and (like me) needs forum bbcode with thumbnail, just modify this line

    PHP Code: 
    $link_code .= '[img]'.$tn.'[/img]'."\n"
    into this
    PHP Code: 
    $link_code .= '[URL='.$lp.'][img]'.$tn.'[/img][/URL]'."\n"
    (for people more newbish than me )

    Although the following line didn't work with remote upload, because remote function returns url with "/images/" instead of "/show/". That will work well when you post it on forum, thumbnail will be loaded, but when you'll click on it, original pic won't be loaded. I've tried changing "/images/" to "/show/", but it didn't work. Normal upload works fine.


    One more question though, I've tried modifying the script to get input from bash like some guy posted HERE but of course, I failed
    Is there a way to do that, so bash command would be something like

    Code: 
    php imagezilla.php my_image.jpg
    Of course this isn't essential for me because I've found my way around it, but I would just want to learn a bit more

    Thanks again for everything!

    Cheers

  9.     
    #18
    Member
    Website's:
    ImageZilla.net
    I've updated the script. Fixed the large picture url and added some code so that you can use it from the command line. If you give the script a url make it starts with "http://". Everything else that doesn't start with "http://" will be consider a file.

    Let me know if there are any bugs. I haven't tested it.

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [Need help] curl / php upload for mediafire?
    By futureawesome in forum Web Development Area
    Replies: 10
    Last Post: 13th Nov 2012, 12:50 PM
  2. [Buying] php cURL upload function only
    By hihotfile in forum Marketplace (Buy, Sell and Trade)
    Replies: 1
    Last Post: 23rd Sep 2012, 02:27 PM
  3. Why curl ftp upload is so slowly?
    By ebogus in forum Web Development Area
    Replies: 0
    Last Post: 12th Jun 2012, 07:57 PM
  4. Upload to Share-online with cUrl
    By skinner in forum Web Development Area
    Replies: 9
    Last Post: 23rd Mar 2012, 01:52 AM
  5. [Hiring] PHP Curl upload/download functions
    By coincoinwc in forum Completed Transactions
    Replies: 1
    Last Post: 29th Sep 2011, 01:18 PM

Tags for this Thread

BE SOCIAL