download from the web to my server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yang Li Ke

    download from the web to my server

    hi guys!
    I want to download images from websites to my server.
    I tried this code but it doesnt work :(
    Can anyone help?
    --
    Yang

    <?
    $fp1 = fopen("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg","r");
    $fp2 = fopen("pics/temp.jpg","w");
    while(!feof($fp 1)) {
    $line = fgets($fp1, 1024);
    fputs($fp2,$lin e,strlen($line) );
    }
    fclose($fp1);
    fclose($fp2);
    ?>


  • Pedro Graca

    #2
    Re: download from the web to my server

    Yang Li Ke wrote:
    [ X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 ]
    [color=blue]
    > I want to download images from websites to my server.
    > I tried this code but it doesnt work :(
    > Can anyone help?
    > --
    > Yang[/color]

    Is this code part of your signature? :)

    [color=blue]
    > <?php
    > $fp1 = fopen("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg","r");
    > $fp2 = fopen("pics/temp.jpg","w");[/color]
    (snip)

    You're on Windows (X-Newsreader header),
    try using the binary translation mode

    fopen('whetever ', 'rb'/*or 'wb' for writing*/);
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • CountScubula

      #3
      Re: download from the web to my server

      "Yang Li Ke" <yanglike@sympa tico.ca> wrote in message
      news:NdNWb.1367 5$y07.507665@ne ws20.bellglobal .com...[color=blue]
      > hi guys!
      > I want to download images from websites to my server.
      > I tried this code but it doesnt work :(
      > Can anyone help?
      > --
      > Yang
      >
      > <?
      > $fp1 = fopen("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg","r");
      > $fp2 = fopen("pics/temp.jpg","w");
      > while(!feof($fp 1)) {
      > $line = fgets($fp1, 1024);
      > fputs($fp2,$lin e,strlen($line) );
      > }
      > fclose($fp1);
      > fclose($fp2);
      > ?>
      >
      >[/color]

      try this:

      $im =
      imagecreatefrom jpeg("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg");
      imagejpeg($im," pics/temp.jpg");
      destroy($im);

      --
      Mike Bradley
      http://www.gzentools.com -- free online php tools


      Comment

      • Chung Leong

        #4
        Re: download from the web to my server

        Try this:

        $f = fopen("temp.jpg ","wb");
        $data =
        file_get_conten ts("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg");
        fwrite($f, $data);
        fclose($f);

        The problem is probably because you left out the "b".

        Uzytkownik "Yang Li Ke" <yanglike@sympa tico.ca> napisal w wiadomosci
        news:NdNWb.1367 5$y07.507665@ne ws20.bellglobal .com...[color=blue]
        > hi guys!
        > I want to download images from websites to my server.
        > I tried this code but it doesnt work :(
        > Can anyone help?
        > --
        > Yang
        >
        > <?
        > $fp1 = fopen("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg","r");
        > $fp2 = fopen("pics/temp.jpg","w");
        > while(!feof($fp 1)) {
        > $line = fgets($fp1, 1024);
        > fputs($fp2,$lin e,strlen($line) );
        > }
        > fclose($fp1);
        > fclose($fp2);
        > ?>
        >
        >[/color]


        Comment

        • Yang Li Ke

          #5
          Re: download from the web to my server


          Fatal error: Call to undefined function: destroy() in
          /home/virtual/site25/fst/var/www/html/test/test.php on line 4

          that doesnt help :(

          --


          "CountScubu la" <me@scantek.hot mail.com> wrote in message
          news:oEQWb.2436 7$un.10108@news svr25.news.prod igy.com...[color=blue]
          > "Yang Li Ke" <yanglike@sympa tico.ca> wrote in message
          > news:NdNWb.1367 5$y07.507665@ne ws20.bellglobal .com...[color=green]
          > > hi guys!
          > > I want to download images from websites to my server.
          > > I tried this code but it doesnt work :(
          > > Can anyone help?
          > > --
          > > Yang
          > >
          > > <?
          > > $fp1 = fopen("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg","r");
          > > $fp2 = fopen("pics/temp.jpg","w");
          > > while(!feof($fp 1)) {
          > > $line = fgets($fp1, 1024);
          > > fputs($fp2,$lin e,strlen($line) );
          > > }
          > > fclose($fp1);
          > > fclose($fp2);
          > > ?>
          > >
          > >[/color]
          >
          > try this:
          >
          > $im =
          > imagecreatefrom jpeg("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg");
          > imagejpeg($im," pics/temp.jpg");
          > destroy($im);
          >
          > --
          > Mike Bradley
          > http://www.gzentools.com -- free online php tools
          >
          >[/color]


          Comment

          • CountScubula

            #6
            Re: download from the web to my server

            "Yang Li Ke" <yanglike@sympa tico.ca> wrote in message
            news:CRaXb.2111 4$y07.647857@ne ws20.bellglobal .com...[color=blue]
            >
            > Fatal error: Call to undefined function: destroy() in
            > /home/virtual/site25/fst/var/www/html/test/test.php on line 4
            >
            > that doesnt help :(
            >[/color]


            oops, up too late that night, should read:

            $im =
            imagecreatefrom jpeg("http://ia.imdb.com/media/imdb/01/I/37/20/46.jpg");
            imagejpeg($im," pics/temp.jpg");
            imagedestroy($i m);



            just make sure the pics dir has correct permissions to allow files to be
            written.

            --
            Mike Bradley
            http://www.gzentools.com -- free online php tools


            Comment

            Working...