Gossamer Forum
Home : Products : Others : Fileman :

Overwriting Files

Quote Reply
Overwriting Files
If I upload a file that has the same name as an already existing file on the server, the server-file will be overwritten.
I want that, in this case, a message appears ("File already exists. Overwrite / Cancel?").
How can I check, if a file with the same name already exists?

Edgar

Quote Reply
Re: Overwriting Files In reply to
This is custom coding.
Try changing the code where it starts the file upload process to do a directory search for a name match, then you'll need another function to display a page with the confirmation text - that's called from main.

Enjoy! It should take about 2 days for a competent Perl programmer.

-- Kevin

Quote Reply
Re: Overwriting Files In reply to
What are you talking about?...2 days???

Try adding this in sub_upload.....

if (-e $fullfile) {
close OUTFILE;
unlink ($fullfile) or &cgierr ("Can't unlink: $fullfile. Reason: $!");
return (0, "Upload: File name already exists.");
}


This won't ask you if you want to continue or not but will stop files being overwritten


Paul Wilson.
Installations:
http://www.wiredon.net/gt/
Quote Reply
Re: Overwriting Files In reply to
But that might not be a great solution when you're trying to have a "repository". For example, I want to create a documentation repository where people will often update certain files. They should be able to edit and overwrite a file, but a warning message will remind them what they are about to do....