Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post

    how do you copy an external file URL to your own server?

    I am trying to copy an image that the user inputs to a local copy on my server.. and for security reasons rename the file


    my form var is: $fileURL

    is this the way to go about doing it or is this potentially a security threat? is there a better way?

    Code:
    $destination = '/www/myserver/images/uploaded/';
    $newname = md5(rand(1,1000));
    copy($fileURL, $destination);
    $filename = not sure how to get the filename from $fileURL
    rename($filename, $newname);
    Last edited by Bobafart; 02-28-2008 at 06:39 PM.

  • #2
    Regular Coder
    Join Date
    Aug 2006
    Location
    Richmond, CA
    Posts
    210
    Thanks
    3
    Thanked 11 Times in 10 Posts
    That's the way I normally do it. The other option would be to not let the person enter a URL, but have a input field of FILE.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •