Results 1 to 4 of 4

Thread: file upload, thought

  1. #1

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720

    file upload, thought

    I made this file upload script, anyway, it lets you upload fine but it overwrites, I guess I can check the filename when the DL is done and output a msg like "name exists, rename?" but how do I make it so the user can pick whatname to upload it as (without renaming locally before uploading) and check if the name is taken BEFORE the upload? I don't want the user to upload a 10 MB file and then have them get a lousy message.
    asdf

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I haven't worked with uploads much, but I believe when you upload, it sends it to a temporary folder.

    Check to see if the file exists, if it does, then when you move it, name it temp.ext and ask the user for a new name. When given, then rename the file.

    Something like that. That's how I'd do it.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: file upload, thought

    Originally posted by scr0p
    I made this file upload script, anyway, it lets you upload fine but it overwrites, I guess I can check the filename when the DL is done and output a msg like "name exists, rename?" but how do I make it so the user can pick whatname to upload it as (without renaming locally before uploading) and check if the name is taken BEFORE the upload? I don't want the user to upload a 10 MB file and then have them get a lousy message.
    Sorry, I guess I missed that you said before the upload.

    When they attempt to upload, check the $_FILES['userfile']['name'] and make sure it does not exist.

    If it does, redirect them to a new page that has both a field for the local file name, and a new field for them to specify a new name.

    Then, when you move the file from the temp on the second submit, you can rename it to the $_POST['newname'], if it does not exist already.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720
    thanks
    asdf

Posting Permissions

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



Click Here to Expand Forum to Full Width