html/php, uploaded files not being stored in $_FIL

2019-03-01 15:43发布

问题:

I have a form where a user submits the description of an object (including an image) and there is JavaScript that adds an additional set of inputs for +1 object description. When the form is submitted the file information is not stored in $_FILES.

The form tag is <form id="order_form" name="order_form" method="post" action="#">

The file type input is <input type="file" name="order_image[]" />.

print_r($_FILES); returns

array()

Does anyone have an idea as to why this might be happening. I will gladly include any other information that might be pertinent to this question.

回答1:

Have you set the correct encoding type in your form tag?

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


回答2:

<form enctype="multipart/form-data" method="POST">

be sure you include enctype