8

I bay this fine-uploader version 3.3.0 now, and integration all lib in my site i think uploads make working its ok, but no! i see error my javascript console:

[FineUploader] Sending upload request for 0

[FineUploader] xhr - server response received for 0

[FineUploader] responseText = 

and error firebug:

[FineUploader] Error when attempting to parse xhr response text (SyntaxError: JSON.parse: unexpected end of data)

at line error: jquery.fineuploader-3.3.0.min.js(line 148)

i use params:

$(document).ready(function () {
    $('#uploader').fineUploader({
    request: {
        endpoint: '/upload/'
      },
    classes: {
        success: 'alert alert-success',
        fail: 'alert alert-error'
         }, 
    text: {
        uploadButton: '<i class="icon-upload icon-white"></i> file target'
      },
       validation: {
      sizeLimit: 31457280 

      },             
    debug: true

    });
  });

if i am write sizeLimit: 10485760 - it all right ok working! file uploads to finish. If write sizelimit: 31457280 file not uploads to end, process break to 2 or 3%. Help me! where bug? Please help me somebody!

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
stopgg
  • 119
  • 1
  • 1
  • 5
  • 1
    Have you looked for errors server-side? That's most likely your problem. – Ray Nicholus Mar 25 '13 at 12:02
  • server-side configuration file php.ini: file_uploads On post_max_size 1024M upload_max_filesize 200M max_file_uploads 200M I checked many times – stopgg Mar 25 '13 at 12:24
  • I uploaded a couple files without issue. The problem is server-side. You will need to take a closer look at your server-side code to figure out what is going wrong. The error you are seeing suggests that an error is occurring server-side. – Ray Nicholus Mar 25 '13 at 13:02

3 Answers3

9

The following log message:

Error when attempting to parse xhr response text (SyntaxError: JSON.parse: unexpected end of data)

Generally indicates your server is not returning a valid JSON response. This is usually caused by an unexpected error server-side. Note that you must ALWAYS return a valid JSON response from your server. If you are using IE9 or older, be sure to return a response code of 200 as well.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Ray Nicholus
  • 19,538
  • 14
  • 59
  • 82
  • This answer would be more useful if you explained how one hunts down the error. – SteveLambert Dec 23 '16 at 18:40
  • I'm not sure what you mean by "hunts down". Perhaps you could explain exactly what you are missing. – Ray Nicholus Dec 23 '16 at 18:42
  • Thanks - so, I'm getting a similar error right now. I suspect I'm not getting a valid JSON response because in the console I'm seeing the html for an apache index page. So, what do I do? How do I go about getting a valid JSON response? – SteveLambert Dec 23 '16 at 18:46
  • There isn't one answer to this question that applies to everyone. In your case, it doesn't sound like you even have a server endpoint configured. The ["Getting Started" guide](http://docs.fineuploader.com/quickstart/01-getting-started.html) walks you through setting up Fine Uploader, and ends with configuring a PHP server. – Ray Nicholus Dec 23 '16 at 18:49
  • Thanks again. Hm, that is what I've been using to get this configured. I ran `npm install fine-uploader` in a directory on my server, followed the instructions for "traditional endpoints" and moved the files into a directory, then specified a directory for the uploads. I gave that target folder 777 permissions. I can see in the console it's reaching that directory. So what am I missing? Do I need to set up something else for that target upload directory? – SteveLambert Dec 23 '16 at 18:58
  • You must have an HTTP server setup to handle the requests. If you start on page 1 of the guide I linked to earlier, the last (3rd) page will walk you through setting up the server. – Ray Nicholus Dec 23 '16 at 19:05
  • I see, I read "all endpoints" as being part of the uploader, and a combination of S3, Azure, and Traditional (which didn't make sense as to why anyone would need that, so I ignored it). Didn't realize that page was to be set up in the target folder to create a gallery. Now that I understand it I wish I had time to make a drawing/diagram of how it works. The writing there wasn't clear to me. It seems you're using the term "endpoint" for the uploader interface *and* the resulting gallery? – SteveLambert Dec 23 '16 at 21:24
  • Endpoint refers to server endpoint that fields the http requests. Gallery is just the UI. Of course your server needs to serve up static resources too, such as the js and HTML, but this isn't library specific. You'll need that sort of setup for any web app. – Ray Nicholus Dec 23 '16 at 21:48
2

I was also facing the same issue with my script which was working on local perfectly but not on server.

Some points we need to ensure:

  1. Set the endpoint correctly as stated here

  2. Make sure your directory where the script is about to upload the file initially (in my case it was example-advanced\uploads ) is write-able. It should have 777 permissions. I was having problem here.

  3. max_file_upload_limit should be set accordingly.

There might be more. But these are few that I have faced so far. Hope this would help somebody.

Community
  • 1
  • 1
KAsh
  • 304
  • 5
  • 23
0

For coldfusion folks this is the code that fixed my issue

<cfoutput>

<cffile
action       = "upload"
fileField    = "QQFILE"
destination  = "#application.OSSandbox#"
accept       = "image/jpeg"
nameConflict = "MakeUnique"
result="imgUploadResult"
/>
<cfset json = CreateObject("component", "#application.CFCRoot#.json2")> // custom code to create a json object
<cfset dataset = json.encode(imgUploadResult,"array")>
<cfset dataset = REReplace(dataset,'("recordcount")','"success": true, \1')>

<cfcontent type="text/plain; charset=ISO-8859-1"><cfoutput>#dataset#</cfoutput>
</cfoutput>
Yoosaf Abdulla
  • 3,722
  • 4
  • 31
  • 34