0

i'm trying to upload a file with php. The usual process is:

form POST->php

But i'm using this method:

form->button with onclick event that calls ajax/javascript function->php script call from javascript

I'm passing the full form (this.form) to javascript, javascript do some stuff and send all the form inputs one by one to php using GET (xxx.php?xxx=xxx&yyy=yyy....), one of those inputs is a FILE , and I don't know how to send it to the PHP script trough javascript function.

Thanks in advance

Jakub
  • 20,418
  • 8
  • 65
  • 92
Ferran
  • 281
  • 3
  • 13

2 Answers2

0

First of all you can't send a file by GET, just use POST, second you need a flash uploader for < IE 8 and for other browser you need an iframe. There is no other solution that i am aware of.

khael
  • 2,600
  • 1
  • 15
  • 36
0

You can use HTML 5 File API to upload file via JS (here is nice tutorial). But you must be cautious, because server may have max URI length limit (see this for more detail).

Community
  • 1
  • 1
Krzysztof
  • 15,900
  • 2
  • 46
  • 76