إذا كنت من مستخدمى الرائع dropzonejs
فقد تكون واجهت مشكلة محيرة بعض الشئ فى عملية ربط الملف المرفوع بالملفات الموجوده فى الصفحة و لعمل ذلك قمت بالإعتماد على الأوبجكت باراميتر file المستخدم مع إيفنت complete الذى يتم إطلاقه عند إنتهاء الرفع
و الخطوات كالآتى :
بعد عملية الرفع .. قم بإرجاع البيانات الخاصة بك على شكل json
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | /// just for test public function upload_media(){         //receive the file here       /// some code         //save the file to server and DB here        /// some code     //return what ever you want here     $data = array(         "name"=>"khashabawy_on_server.png",         "img_id"=>33423     );         echo json_encode($data);     } | 
بعد ذلك عليك أن تستخدم إيفنت complete كالآتى :
| 1 2 3 4 5 6 | this.on("complete", function(file) {     var my_data = file.xhr.response;     var data = jQuery.parseJSON(my_data);       file["name"]= data.name;     file["img_id"]= data.img_id; }); | 
أصبح الآن الأوبجكت file يحتوى على index بإسم name و آخر بقيمة img_id و كل منهما لهما القيمة المناظره التى رجعت من السيرفر
الآن إن رغبنا بحذفهما نقوم بالإستماع إلى إيفينت removefile كالآتى :
| 1 2 3 4 5 6 | this.on("removedfile", function(file) {     //logging to see     console.log(file.img_id);     /// remove from server       /// send an ajax request with the file data you got before }); | 
