If you are asking if you can set a filename in the value of a type=‘file’ field, the answer is no. You can clear it, by setting it to an empty string, but you cannot set it to a filename through any programmable means, as that would allow someone to specify and upload any file off of a computer. The value can only be set to a filename through the browser’s file selection dialog.
If you want to list existing files, you would need to display them somewhere in the vicinity of the form field.
If you want to programmatically compare selected file(s) with a list of existing filenames, to display a message, you can do so.
I was hoping to add the image name so I could reference it on server side afterwards (file.filename) to check if it is the same as the database, and only add other images if they don’t exist already.
But I think i will run two scripts, first to check if the image can stay already up loaded if exists, and then run the second file script to upload any newer images in the form.
Filenames can be set to anything. Someone could upload the same file, a 1000 times, with a different name each time or upload a different file with the same name as an existing file.
Also, you wouldn’t pass server-side information through the browser and use it on the server, since anything that comes from the browser can be manipulated and cannot be trusted. You would perform any validation wholly on the server after the data has been submitted.
Basically a user adds images to the website, when they are uploaded to the server I change the filename to a unique value and this name gets stored in the database.
When it comes to edit the images I load them into the form using the file on the server.
If the user clicks an image it removes the image and also the database reference.(8 boxes/inputs can be loaded or used on the screen.
But if some images are not being changed I want to check server side to add new input images only and keep the original name in database and only add the new images using normal file transfer in PHP.
Basically check the database to previously uploaded image/filename and check if exists or not