Good day!
I have such a problem - I am going to upload pictures to the site without reloading the page via ajax.
There is such a form:
<form name="uploadimages" method="post" enctype="multipart/form-data"> <input id="uploadimage" type="FILE" name="uploadimage" id="uploadfile"> </form> and this is the function that should send the Ajax file from the download field to the handler like this:
<script type="text/javascript"> function setimage() { var uploadfile = $("#uploadimage").val(); $.ajax({ type: "POST", url: "uploadimages.php", data: "img=" + uploadfile, success: function(html){ $("#textar").append(html); } }); } </script> There are no problems with this, everything works in the handler, except for one thing - there is a resize function that works separately too!
It looks like this:
//тут объявляется функция $img = $_POST['img'];//получаем данные $image = imageResize($img, 'litimages', 1000, 1000);//делаем ресайз (пареметры - картнка, директория для сохраненияя, размеры) $image = "<br><br><img src='".$image."' width='700'><br><br>"; //вставляем в тег адрес echo $image; //и возвращаем Everything is logical, but in fact gives an error:
Catchable fatal error: Argument 1 passed to imageResize () must be an array of string, given, called in Z: \ home \ superli \ www \ uploadimages.php on line 92 and defined in Z: \ home \ superli \ www \ uploadimages. php on line 5
This, as for me, is related to the fact that here
var uploadfile = $("#uploadimage").val(); The name of the picture is sent, and not the picture itself.
Please help me figure out how to properly send the file itself, thanks in advance!
$_FILES['img']), although here I could be wrong. - RubaXa