0

I have a little problem about upload files in ajax. I sent a form-data to my backend server. The problem is that sometimes, depending on the files my backend doesn't receive anything. Nothing on $_REQUEST, nothing on $_POST, $_GET, $_FILES or even in file_get_contents(php://input).

I have already tried to put my memory_limit to -1 with post_max_size to 0 and my upload_max_filesize to 16M.

I tried with a small picture, an heavy one and one between the two. The small failed. The heavy and the other one are good.

Did any of you have a clue about this problem ?

Edit : I'm using angularJS (angular 1.x.x) on my front-end.

halfelf
  • 9,737
  • 13
  • 54
  • 63

1 Answers1

0

Did you set the form encoding type to multipart/form-data?

<form action="foo.php" enctype="multipart/form-data" method="post">...

You didn't say how you were sending the files to the server via AJAX, but this SO answer Angularjs $http post file and form data would probably be helpful to you.

Dan Morphis
  • 1,708
  • 19
  • 23
  • That's an excellent question. Indeed my request is in multipart/form-data. Like I said, in some test it's working without any problem. Even if it's not working my developers console show me that my request is perfectly sent. Sorry about my english. – Rayan DJEBLI Apr 16 '19 at 21:48
  • Sorry, I missed the part in your question where you said some of the files were getting through. – Dan Morphis Apr 17 '19 at 16:16
  • I'd fire up Fiddler and see whats different between the requests that do, and do not work. Unfortunately, this is probably going to be a maddening problem to solve, and the solution will turn out to be something really simple, and minor :(. – Dan Morphis Apr 17 '19 at 16:17