1

I am using the BlueImp jQuery-file-upload to upload files to server. The upload accounts for files that may have the same name appending (1),(2)...etc. The issue that I am having I am sure results from the following code

$('#albumCover.fileupload').bind('fileuploaddone', function(e,data) {

        //Loop through each uploaded file and return object
        $.each(data.files, function (index, file) {
            var filename = file.name;
            $.ajax({ 
                type: "POST",
                url: "../albumUploader/queries/albumCover.php",
                data: {file: filename}
            });
        });
}

I am posting to albumCover.php whatever filename I am selecting, so if it happens to be a duplicate of an existing file, the DB will have duplicate "image.jpg", while the uploader is correctly uploading the files appending (1),(2) etc.

Is anyone familiar how I pass the filename that the uploader is correctly labeling the uploaded files. I should be sending to albumCover.php, and is the POST type the correct type to be using in this situation.

1 Answer 1

1

Hope this helps someone else. Here is where I found my rescource: https://github.com/blueimp/jQuery-File-Upload/issues/641

   $('#albumCover.fileupload').bind('fileuploaddone', function(e,data) {
    var filename = data.result[0].name;
            $.ajax({ 
                type: "POST",
                url: "../albumUploader/queries/albumCover.php",
                data: {file: filename}
            });
    }

the data.result[0].name returns the amended file name

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.