|
-
Apr 29th, 2003, 08:27 PM
#1
Thread Starter
Fanatic Member
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.
-
Apr 29th, 2003, 08:52 PM
#2
Stuck in the 80s
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.
-
Apr 29th, 2003, 08:57 PM
#3
Stuck in the 80s
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.
-
Apr 29th, 2003, 09:29 PM
#4
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|