cubiclesoft / jquery-fancyfileuploader

A jQuery plugin to convert the HTML file input type into a fancy file uploader under a MIT or LGPL license. Mobile-friendly too!
58 stars 27 forks source link

File uploads PHP failed #2

Closed leelennie closed 6 years ago

leelennie commented 6 years ago

Hi, I'm using a simple PHP for file upload submissions to the server rather than using the Admin Pack or FlexForms as you mentioned(not sure if this is okay as I'm not that familiar with all the coding). I'm facing issues whereby either (1) the upload is failed or (2) files uploaded successfully but the error stated failed.

For example, I tried with the uploader from blueimp's file upload plugin

error_reporting(E_ALL | E_STRICT);
require('lib/UploadHandler.php');
$options = array ('upload_dir' => dirname(__FILE__) . '/uploads/');
$upload_handler = new UploadHandler();

Outcome: File uploaded successfully even showing 100% but ff_fileupload_errors stated "The upload is failed".

May I know how should I configure the code to use blueimp's file uploader?

Appreciate if you could help me on this issue!

cubiclesoft commented 6 years ago

The most likely reason for successful file uploads and a failure response from Fancy File Uploader is that this uploader widget expects a formatted JSON response from the server. The blueimp file uploader class doesn't respond with JSON in a compatible format. Fancy File Uploader is a layer over the core blueimp library but doesn't really adhere to how blueimp does things beyond that, so I'm not surprised that his class doesn't work here.

I realize that there are people like yourself who don't want to introduce a dependency on FlexForms (even though it is a fantastic piece of software). So I just added a PHP FancyFileUploaderHelper class to this repository and some example code. FancyFileUploaderHelper contains all of the relevant static functions from FlexForms Modules and FlexForms in a single self-contained class. The example code is borrowed from Admin Pack and adjusted accordingly to use the new class. I haven't tested this particular class or the example PHP code, but both should work fine for your needs.

leelennie commented 6 years ago

Hi, thank you so much for your help! I'm now able to upload files successfully and return result with "Upload completed"!

However, I would like to enquire another question about sending email. I have opened a new issue in case it's irrelevant with this topic.

cubiclesoft commented 6 years ago

Glad to hear you got it working. Closing out this issue.