php - How i can upload my file to DB mysql with Jquery EasyUI? -



php - How i can upload my file to DB mysql with Jquery EasyUI? -

i'm working jquery easyui , have problem code. have form input file db , form has input type = file want allow attachment. however, when form submitted, $_files object has nil in db , path declared.

i hope can help me solve problem code. give thanks you

here listening code:

<form id="form" method="post" enctype="multipart/form-data"> <input type="file" name="file_att" id="file_att" size = "30px;" class="easyui-validatebox" required="true"/> </form>

here code run form when form submitted:

<?php include "../inc/inc.koneksi.php"; $file_att=$_files["file_att"]["name"]; $target="file_att/$file_att"; $temp=$_files["file_att"]["tmp_name"]; $query=mysql_query("insert t_director(id_direc,file_att) values ('null','$file_att')"); if(!empty($file_att)){ move_uploaded_file("$temp","$target"); echo "success attached"; } else {echo "failed";} ?>

my bet fail upload file reason. seek next code:

if(move_uploaded_file($temp, $target)) { echo "file uploaded"; } else{ echo "error!"; }

instead of:

move_uploaded_file("$temp","$target"); echo "success attached";

if outputs , error, seek var_dump($_files["file_att"]); error code. more info on error codes can found here.

also, file located @ $_files["file_att"]["tmp_name"] before move it, save it's file name within database, not file itself.

third: stated within comments, utilize mysqli/pdo and, sanity's sake, create file limit with

<input type="hidden" name="max_file_size" value="xxx">

where xxx value in bytes.

edit: also, check server's post_max_size , upload_max_file_size.

php jquery mysql forms jquery-easyui

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -