blueimp / jQuery-File-Upload

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.
https://blueimp.github.io/jQuery-File-Upload/
MIT License
30.94k stars 7.95k forks source link

Error: SyntaxError: Unexpected token < #647

Closed Dacarts closed 12 years ago

Dacarts commented 13 years ago

Hi im trying to upload images files but everytime i push upload

i get this - Error: SyntaxError: Unexpected token <

pleas help and thx for any help.

notflip commented 10 years ago

Fixed it! The problem was that a warning was being outputted by the console. This disturbed the return I fixed the warning regarding the Timezone and it's now working

butch2k commented 10 years ago

Check the server repsonse content. It should point to the error/warning cause.

On Mon, Jun 9, 2014 at 1:37 PM, melcarthus notifications@github.com wrote:

notflip you said you fixed it but you don't post any solutions. Im having the same error message when I want to upload images. I get the json error when clicking upload.

— Reply to this email directly or view it on GitHub https://github.com/blueimp/jQuery-File-Upload/issues/647#issuecomment-45482637 .

melcarthus commented 10 years ago

It would be helpful of everyone who is posting a solution to also put in a little more detail. Like where the files are that they are mentioning. The error i'm having probably has to do with permission but they are set als they should...

SyntaxError: Unexpected token g OK guage->get('error_permission');
}

    if (!isset($json['error'])) {   
        if (@move_uploaded_file($this->request->files['image']['tmp_name'], $directory . '/' . $filename)) {        
            $json['success'] = $this->language->get('text_uploaded');
        } else {
            $json['error'] = $this->language->get('error_uploaded');
        }
    }

    $this->response->setOutput(json_encode($json));
}
Matheus7777777 commented 10 years ago

Must use absolute url instead of relative

www.site.com.br/assets/

Do not use

.. / .. /

ingelity commented 10 years ago

I had the problem with "SyntaxError: Unexpected end of input", for which the problem was that url in fileupload was incorrect(I forgot to update it).

And the problem with "SyntaxError: Unexpected token <" is probably that you are printing out something on server in action/function which is handling the file upload. UploadHandler is already generating a response and if you print out something as well it's probably gonna break.

notflip commented 10 years ago

Like @ingelity says you can only return a clean output, I was getting a warning returned with the input regarding the timezone not being set. When i fixed the warning it all worked well

ghost commented 10 years ago

took me a while to get it... below is what worked for me. i had changed the location and renamed the "server/php/" folder and that is why i was getting the error. To fix the issue i had to edit the "js/main.js" file. go to line:18. it looks like: $('#fileupload').fileupload({ // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, url: 'server/php/' });

so i changed it to point to my new "server/php/" which is now "inc/file_upload/" folder to look like:

$('#fileupload').fileupload({ // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, url: 'http://localhost/mysite/inc/file_upload/' });

...and the error was gone! i hope this helps.

k790126 commented 10 years ago

new \Imagick -> new Imagick new \stdClass -> new stdClass

Slimboy92 commented 10 years ago

I had the same problem after integrating the plugin into my website. The problem was the mod_rewrite my cms is using. I fixed that with giving an absolute path to the server/php/ directory in main.js at line 21. May others having the same scenario.