Hello, I´m creating a system of uploading files. I want to know if there is a way I can check if the file that is being uploaded already exists at that destination before I actually upload the file, and if it is, alert the user about that before doing anything.
The technical answer is, No. By the time your PHP code starts executing, the file has already been uploaded and stored under the temporary file name and location. At that point, you can certainly check if the permanent file name already exists at the location to which you plan to move the file. Is that what you want?
Check out the file_exists() function.
A related topic -- and possible alternate method of handling existing file names:
To check that the temporary file has been uploaded ok, use the is_uploaded_file function;
if (is_uploaded_file($temp))
{
move_uploaded_file(string $filename, string $destination);
}
else
{
//nothing there
}
Then use file_exists to check that the file is on your server.
dc
Voyager Web Design UK
Web Design::Custom Programming::Custom Graphics
------------------------------------------------------- M-Dream
Asian Cinema::Asian Music::Asian Cover Scans::Chinese Astrology::Free PHP Scripts::Hong Kong Photo Galleries
Awww, you put the sequence number on the beginning of the file name. Why did you not want to put the sequence number on the end of the file name (before the file extension) as I supplied the code in that other thread link I gave you?
Bookmarks