You cannot upload files via conventional AJAX (XMLHttpRequest).
There are several around it, most commonly to do a normal submit of
the upload form to a hidden iframe.
There are many articles around on that if you do a search.

On Feb 5, 5:58 am, "david.0pl...@gmail.com" <david.0pl...@gmail.com>
wrote:
> Disclaimer: I know there are plugins for this but I'm trying to learn
> to do things myself before using other people solutions!
>
> I have a nice form that send data like this:
>
> var nome = $("#nome").attr("value");
> var hyperlink = $("#hyperlink").attr("value");
> var gruppi = $("#gruppi").attr("value");
> var data_f = $("#data_f").attr("value");
> var stato = $("#stato").attr("value");
> var uploadedfile = $("#uploadedfile").attr("value");
> .
> then goes the ajax:
>
> $.ajax({
>
> type: "POST", url: "func/ajax.uploader.php",
> data: "_invia_check=1&nome=" + nome + "&hyperlink=" + hyperlink +
> "&gruppi=" + gruppi + "&data_f=" + data_f + "&stato=" + stato +
> "&uploadedfile=" + uploadedfile,
>
> //Mentre carica il responso!
> beforeSend: function(){$("#loading").show("fast");},
> complete: function(){ $("#loading").hide("fast");},
> //Richiesta completata! Riscriviamo l' html!
> success: function(html){$("#banner_inserisci").html(html);}
>  });
>
> On the backend there is data manipulation (php) and sql queries.
> Now the problem arise when i need this:
>
> $target_path = '../../' . $target_path . basename( $_FILES
> ['uploadedfile']['name']);
> if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'],
> $target_path)) {..}
>
> How I can pass the $_FILES variable in javascript??
>
> Thanks

Reply via email to