upload file from URL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Berrow

    upload file from URL

    I have an input box for uploading image files

    <input type="file" name="userfile" size="35" >

    This works upload from my machine, but if I paste in a URL, the
    following:

    if (($_FILES['userfile']['type']=="image/gif") ||
    ($_FILES['userfile']['type'])=="image/pjpeg" ||
    ($_FILES['userfile']['type']=="image/jpeg"))

    returns false even if the file is a .gif or a .jpg.

    How do I upload pics from a URL?
    --
    Geoff Berrow
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/
  • Alan Little

    #2
    Re: upload file from URL

    Carved in mystic runes upon the very living rock, the last words of Geoff
    Berrow of comp.lang.php make plain:
    [color=blue]
    > How do I upload pics from a URL?[/color]

    You don't upload files from a URL. You upload files from your computer. If
    you want to open a URL, ensure that allow_url_fopen is set to true in your
    config, and use fopen():



    --
    Alan Little
    Phorm PHP Form Processor

    Comment

    • John Dunlop

      #3
      Re: upload file from URL

      Geoff Berrow wrote:
      [color=blue]
      > I have an input box for uploading image files[/color]

      Although probably much improved, browser support for file uploads
      is (still?) not universal. So consider offering users alternative
      methods to transfer the data.
      [color=blue]
      > How do I upload pics from a URL?[/color]

      RFC2388 sec. 5.7 outlines one possible way of referencing data at
      an URL:

      | In some scenarios, the user operating the client software might
      | want to specify a URL for remote data rather than a local file.
      | In this case, is there a way to allow the browser to send to the
      | client a pointer to the external data rather than the entire
      | contents? This capability could be implemented, for example, by
      | having the client send to the server data of type
      | "message/external-body" with "access-type" set to, say, "uri",
      | and the URL of the remote data in the body of the message.



      But current browser support is unsurprisingly nonexistent, to my
      knowledge. Does anyone know a browser that implements this?

      The intention of the HTML specification is that users are able to
      choose a file from their local filesystem. Browsers usually offer
      the user the option of browsing their filesystem to pick out a
      file, but I can't see any reason why a user cannot enter a full
      local pathname directly, such as "C:\temp\image. png" [1].


      [1] I was going to type ".jpg", but you've seen this, right? ;-)


      --
      Jock

      Comment

      Working...