Search code examples
phpajaxuploading

Get image name when uploading


I have form input as follows:

-------------------------Form-------------------------

Title : [text box]

Category : [Combobox]

Content : [Text area]

Images : [File with multiple choose]

[button]

------------------------End Form-----------------------

I am using PHP and AJAX when inserting data but have problems with uploading. I cannot get the file name (Image name) for uploading and inputting to the database.

Here is a little of my AJAX script:

data = "action=add&kode="+kode+"&file="+image+"&title="+title+"&categori="+categori+"&content="+content;
$.ajax({
    url: "action/prosesPOST.php",
    type: "POST",
    data: data,
    cache: false,
    success: function(msg){
        if(msg=="yes"){
        }else{
            $("#status").html("Failed...");
        }
        $("#status").html("");
        $("#loading").hide();
        $("#form-box").fadeOut("fast");
        $("#table").load('action/prosesPOST.php?action=loaddata');
    }
});

Solution

  • Update:

    Ajax cant handle "uploading image" so i use hidden iframe method, like the comments the best way for me,

    Like this methode