Image Download

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • funkychicken818@gmail.com

    Image Download

    Hey well i need help i want to create a simple image downloading script
    where you insert the image URL and it will download it and place it on
    your server, and rename the image to some number. Any one have any
    ideas on how i can do this?

  • Erwin Moller

    #2
    Re: Image Download

    funkychicken818 @gmail.com wrote:
    [color=blue]
    > Hey well i need help i want to create a simple image downloading script
    > where you insert the image URL and it will download it and place it on
    > your server, and rename the image to some number. Any one have any
    > ideas on how i can do this?[/color]

    Hi,

    Go to www.php.net and look up:
    1) How to post and receive a formelement (using $_POST probably)
    2) have a look at a function called fopen.
    (It also handles http-requests if php is configured to do so.)


    3) Safe the content on your server somewhere under a name.
    read more here:


    Good luck

    Regards,
    Erwin Moller

    Comment

    • funkychicken818@gmail.com

      #3
      Re: Image Download

      thanks

      Comment

      • Rik

        #4
        Re: Image Download

        funkychicken818 @gmail.com wrote:[color=blue]
        > Hey well i need help i want to create a simple image downloading
        > script where you insert the image URL and it will download it and
        > place it on your server, and rename the image to some number. Any one
        > have any ideas on how i can do this?[/color]

        "simple" and "place it on the server" don't really mix if you want the
        script to be save (you could end up with malicious content on your
        server...)

        Without the security, your script could be like this though (PHP > 4.3.0):

        $url = "http://some/url/of/image.jpg";
        preg_match('"(\ .[^/]+)$"', $url, $match);
        $extension = (isset($match[1])) ? $match[1] : '';
        $int = 'your_number';
        $handle = fopen($url, 'r',);
        copy($handle, '/path/on/your/server/'.$int.$extensi on);

        Grtz,
        --
        Rik Wasmus


        Comment

        • funkychicken818@gmail.com

          #5
          Re: Image Download

          hey there is a error.
          Parse error: syntax error, unexpected ')' in
          /home/creative/public_html/mysitesucks/Test/image_graber.ph p on line 14

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
          />
          <title>Untitl ed Document</title>
          </head>

          <body>
          <?php
          $url = "http://mysitesucks.com/images/MSS_web_01.jpg" ;
          preg_match('"(\ .[^/]+)$"', $url, $match);
          $extension = (isset($match[1])) ? $match[1] : '';
          $int = '1234567';
          $handle = fopen($url, 'r',);
          copy($handle,
          '/home/creative/public_html/mysitesucks/Test/images/'.$int.$extensi on);
          ?>
          </body>
          </html>

          Comment

          • denisb

            #6
            Re: Image Download

            funkychicken818 @gmail.com <funkychicken81 8@gmail.com> wrote:[color=blue]
            > hey there is a error.
            > Parse error: syntax error, unexpected ')' in
            > /home/creative/public_html/mysitesucks/Test/image_graber.ph p on line 14[/color]
            [color=blue]
            > $handle = fopen($url, 'r',);[/color]
            _______________ ____________^ ???


            hey ! too

            --
            @@@@@
            E -00 comme on est very beaux dis !
            ' `) /
            |\_ =="

            Comment

            • funkychicken818@gmail.com

              #7
              Re: Image Download

              denisb wrote:[color=blue]
              > funkychicken818 @gmail.com <funkychicken81 8@gmail.com> wrote:[color=green]
              > > hey there is a error.
              > > Parse error: syntax error, unexpected ')' in
              > > /home/creative/public_html/mysitesucks/Test/image_graber.ph p on line 14[/color]
              >[color=green]
              > > $handle = fopen($url, 'r',);[/color]
              > _______________ ____________^ ???
              >
              >
              > hey ! too
              >
              > --
              > @@@@@
              > E -00 comme on est very beaux dis !
              > ' `) /
              > |\_ =="[/color]

              What id on't understand?

              Comment

              • Rik

                #8
                Re: Image Download

                funkychicken818 @gmail.com wrote:[color=blue][color=green][color=darkred]
                >>> $handle = fopen($url, 'r',);[/color]
                >> _______________ ___________^ ???[/color]
                > What id on't understand?[/color]

                He is pointing to a comma that either shouldn't be there or should be
                followed by a boolean indicating to use the include_path. Reading in a
                fixed-width font would have clarified that.

                hey! too by the way :-)

                Grtz,
                --
                Rik Wasmus


                Comment

                Working...