i have a form that with a link click adds a new for a file with jquery’s .html()
// show div to change image on product_edit.php
$("#change_img").click(
function () {
$("#change_img_div").html('<label>Image product</label><input type="file" value="" name="item_img" id="item_img"/>').fadeIn('fast');
$(this).fadeOut('fast');
}
)
When I choose a file and I submit this name “item_img” is not present in the php $_POST array,
if I put type=”text” instead the new input is passed to POST.
Basically seems like a “file” type is not recognized if this is not present in the html if the first place?
Files are sent as binary data and as per the HTML specification, it requires the
<form>to be set withenctype="multipart/form-data"so that it can be mixed with text content (the normal request parameters). In the PHP side, they are available by the$_FILESarray.See also: