Welcome Guest, Not a member yet? Register   Sign In
File Uploading class - how to retrieve filename before uploading file?
#1

[eluser]stuart_g[/eluser]
I would like to know the filename of the file before I upload it, as I want to inform the user it's got the same filename as another file rather than just ovewriting or creating a duplicate with a different name.

Is this possible?

Thanks
#2

[eluser]pistolPete[/eluser]
I guess you have to access $_FILES directly before using the upload library.
Another option is to extend the upload library.
#3

[eluser]tobben[/eluser]
You could maybe use some javascript. Something like (a bit pseudo and real code here..) :

HTML
<input type="file" name="files" id="files" />

Code:
var fileNameToCheck = '';
$(function(){
    $('#files').change(function(){
        fileNameToCheck = $(this).val();
        
        // Do some Ajax-stuff to a PHP script that checks the existens of a given filename/filepath
        // Return value and show a response to the user "OMG! Duplicate file!!!!"
    });
});




Theme © iAndrew 2016 - Forum software by © MyBB