Closed Dacarts closed 12 years ago
i just run the test and i got these errors
Triggers destroy callback
Passes over deletion url parameter
Expected:
"test"
Result:
""
Diff:
"test" ""
Source:
at HTMLDivElement.
"DELETE"
Result:
""
Diff:
"DELETE" ""
Source:
at HTMLDivElement.
"test"
Passes over deletion request type parameter
Expected:
"DELETE"
Expected 3 assertions, but 6 were run
but i don´t know what to look for to change that please advise ?
Hi, I am getting the same error. Were you able to resolve it?
Hi, try setting the display_errors to 0 in your upload.php. Also, there could be issues with your folder perm. I had to set mine to 777 (unsafe but that's what it took)
I had this problem because I didn't have PHP installed.
I am also having this issue. I definitely have php installed, and kadaji's solution seems to be avoiding the issue rather than solving it (no offense meant). Any other solutions or clues?
I just recently began having the "SyntaxError: Unexpected token <" error message. The strange thing is that it happens only when I upload large files (over 500 KB). When I upload ~50KB JPG files, they work just fine.
I am running this on an IIS server and am using the Classic ASP example code posted on this site with ASPUpload.
Any ideas?
@coolguy982 Sounds like you're being given HTML instead of json. Dump the full response from the page, you might be hitting an upload limit or something.
@damianb What is the easiest way to dump the full response from the page? Do I need to do this within a jquery upload js file?
I have the same issue , although I generate a valid json string and checked that at jsonlint.com.
This is a sample of json output :
[{"name":"29bbd4bf77c07c38c572a60c8547bd15_123646715_original.jpeg","size":36.05,"type":"image\/jpeg","url":"\/Users\/ams\/Code\/damlag\/elcinema\/src\/elcinema.com\/app\/public\/photos\/38\/123646715\/29bbd4bf77c07c38c572a60c8547bd15_123646715.jpg","thumbnail_url":"http:\/\/www.elcinema.ci\/photolist\/38\/29bbd4bf77c07c38c572a60c8547bd15_123646715_101.jpg","delete_url":"http:\/\/www.elcinema.ci\/backend\/upload\/delete_file\/123646715","delete_type":"DELETE"}]
I had a similar issue. Turns out that when I changed the "orient_image" option variable in the PHP UploadHandler class constructor from false to true, I was getting the infamous "SyntaxError: Unexpected token <." There seems to be an issue with the file_path. When I changed the "orient_image" option back to false, the erros went away.
It's weird, cause the unzipped package works fine untouched, but when I moved the UploadHandler class to the CodeIgniter library folder, changed the options, and moved some code into the controller, all of a sudden the error started popping up. I'm trying to find another spot where the file_path is defined, that I may have missed. Other than that, everything works fine.
Not sure why the example downloaded from github works, but the reason why I was getting the error is because when orient_image is set to true, the function called a php function exif_read_image(), which only supports exif data from JPG and TIFF files, NOT PNG, which is what I was using. So, when exif_read_data ran on my .png file, php was throwing a warning message, messing up the json response.
Anyway, not sure how useful the orient_image function is, but just keep that in mind. You'll want to add some code to execute the orient_image function only if the extensions are .jpg or .tiff.
Cheers!
Setting error_reporting(0) resolved the error being returned, for me. But though the upload worked, a thumbnail copy was still not being created.
I have the same problem.... what we can do ???
It might be that the thumbnail wasn't generated after the upload - Check the folder perms. FYI, the thumbnail is stored in a different folder as the uploaded file.
On Wed, Feb 15, 2012 at 8:45 AM, rob478 < reply@reply.github.com
wrote:
I have the same problem.... what we can do ???
Reply to this email directly or view it on GitHub:
https://github.com/blueimp/jQuery-File-Upload/issues/647#issuecomment-3980357
I'm on local so no problem of folder perms
do you see a thumbnail generated in the folder?
On Wed, Feb 15, 2012 at 8:50 AM, rob478 < reply@reply.github.com
wrote:
I'm on local so no problem of folder perms
Reply to this email directly or view it on GitHub:
https://github.com/blueimp/jQuery-File-Upload/issues/647#issuecomment-3980453
No, there is only the image on files.
if you don't see the thumbnail in its folder, its either folder perm issues (doesn't matter if you are on local) or your php was compiled without the graphic lib.
Do the folder perms match for 'files' and 'thumbnails' ??
On Wed, Feb 15, 2012 at 8:57 AM, rob478 < reply@reply.github.com
wrote:
No, there is only the image on files.
Reply to this email directly or view it on GitHub:
https://github.com/blueimp/jQuery-File-Upload/issues/647#issuecomment-3980549
The perms are the same. I have try on the server, I have the same error... It's possible that php was compiled without the graphic lib, How can I verify this ?
I have this : GD Support enabled GD Version bundled (2.0.34 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.3.9 GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version 6b PNG Support enabled libPNG Version 1.2.37 WBMP Support enabled XBM Support enabled
phpinfo()
also you can debug the function create_scaled_image() in upload.php and see where its failing.
On Wed, Feb 15, 2012 at 9:07 AM, rob478 < reply@reply.github.com
wrote:
The perms are the same. I have try on the server, I have the same error... It's possible that php was compiled without the graphic lib, How can I verify this ?
Reply to this email directly or view it on GitHub:
https://github.com/blueimp/jQuery-File-Upload/issues/647#issuecomment-3980726
How can I debug the function ?
Hopefully this will help some one, however, reading this post it sounds like a variety of errors. This is what fixed this error for me.
Set the "post_max_size" and "upload_max_filesize" in the php.ini or using php_values in .htaccess file. ini_set doesn't work for php because it is executed too late, the file is already uploaded before the file reaches your script.
In this situation, the unexpected token is a html error, I came across this from testing as debugging was not giving me any results by echoing variables because the error was happening even before the script was loaded. To help speed this up you can also check your server error logs for apache and will tell you in there as well. You could also go as far as turning on your php errors to write to a file, if it is not already.
I was getting the same issue. Somehow, someway, the thumbnails directory has to be set to 777 not 755. Once I set it to 777, the error went away.
Same issue. Unzipped and uploaded strait out of the box. In Chrome I get 'SyntaxError: Unexpected token <' after i start upload. In Firefox it says 'SyntaxError: JSON.parse: unexpected character' But firebug doesn't show an error. The thumbnail shows after I choose the file but disappears after 'start upload'
I've set the permissions to 777, and 755 I've set my php.ini to 'upload_max_filesize = 20000000' & 'post_max_size = 20000000'
In the test page I only get to 14. Callbacks: done (0, 1, 1)Rerun Running Callbacks: fail
Any suggestions?
Hi, i have the same probleme, i downloaded et uploaded it straigthaway but it didn't work.. i always have "SyntaxError: Unexpected token <" at the end of the upload.
I tryed to change the access of file and thumbmail but it still not work.
Someone fixed this problem?
Thanks
I had the same problem here, as solution i put "error_reporting(E_ALL | E_STRICT)" into a comment "//error_reporting(E_ALL | E_STRICT)" and it works fine no more "SyntaxError: Unexpected token <"
Still not work =/
i got this error "SyntaxError: Unexpected token <" because error report inject some html code into the JSON response
@newenth use firebug or wireshark to track the origin of your error.
"Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' on line 15"
Line 15 is "protected $options;" .. i don't understand =/
Oh gosh, i fixed it!
I created a .htaccess 0604 on the root of my FTP with: "SetEnv PHP_VER 5_TEST SetEnv REGISTER_GLOBALS 0"
and it works..
GREAT!
Hola
Resulta que el modulo me estaba funcionando bien cuando lo registre en un hosting gratuito donde lo tenia alojado... decidi comprar uno y migre toda la pagina.
Ahora cuando le doy a agregar un archivo el funciona correctamente... le doy a cargar y efectivamente la barra de progreso va en aumento mientras se carga el archivo... pero cuando termina de cargar me muestra al lado de la barra un error "SyntaxError: Unexpected token <".
Alguien podria ayudarme? la verdad es que no he podido arreglarlo por mis propios medios...
GRACIAS DE ANTEMANO!
Thank you @khammami! I had this error and ended up using firebug to narrow the issue down to my upload.class.php script which caused the error.
I was getting the same issue. Somehow, someway, the thumbnails directory has to be set to 777 not 755. Once I set it to 777, the error went away.
Dear all,
I would just like to hide the error. I have integrated the plugin into an existing Druobox uploader php class and it works perfectly, except it throws me this "Syntax Error : Unexpected Token <".
I have searched for an extra "<" in almost all the documents in the plugin, but I feel this is useless, since I am not using the php server class or anything of that type.
Since everything works fine otherwise, I would just like to hide the error, but I still need to be able to display the "File Too Large" or "Wrong Format" message, so I can't hide all errors with CSS.
Any idea?
I was having an issue with this in running the demo app. The problem was non-existant or incorrect permissions on the files/ and thumbnails/ directories. Firebug as mentioned above would work well for tracing the problem if you're still having it. You can also use google Chrome this way:
This should show you the HTML error messages being returned which cause the "Unexpected Token <" problem.
Thanks a lot for your help, but unfortunately, when I try to debug this both in Firebug and with the Chrome Developper's tools, no error shows up. As I said, since I have inserted a PHP class that uploads files directly to dropbox, I don't think the php code from the Jquery Upload app is being triggered... At least there is no /server/php script triggered in the network tab in the Chrome Developper's Tools. I was thinking this error was maybe only coming from the JSON message that's being output after the upload and that it may be at least hidden or changed with some JSON manipulation. But I don't really understand how this works, so I am a bit at loss to do so...
Is what I am saying making any sense? Any idea about how to hide this error message?
As I also said, the script works perfectly otherwise...
Not to clutter the discussion, but to be more precise, my idea here (which is obviously a dirty fix, but I cannot access the permissions of the dropbox) would be to be able to "grab" the specific "Syntax Error : Unexpected Token <" in the "errors" settings of the locale.js file so that instead of outputting this error, it would say "Your File Has Been Correctly Uploaded".
I tried with "syntaxError": "Your File has been successfully uploaded", and "SyntaxError", but without success. Of course, since I cannot display the server side error in any debugging platform, it makes it much harder...
The problem is that the server, your PHP class in your case, /server/php/index.php in my default case, is returning HTML error messages which the javascript client is trying to parse as JSON. The php server probably should return JSON errors instead. Using the developer tools is a way to track the current problem down to fix it.
oops my bad @chriscct7 i didn't read your comment i was so happy that i solved the problem that i posted here without reading your comment ...
@jsheedy you saved me man..... much appreciated........
i have a same error Error SyntaxError: Unexpected token < any solution please ?
I had this error too (Error SyntaxError: Unexpected token <). This was because I had copied the main libraries into a different folder and put the uploader html file (the main view) somewhere else. When I included the main.js in this file it expectec to find the server side script (php) at /server/php/ and couldnt. So just needed to correct the path on line 22 of main.js so that it could post successfully to the script.
i had the same error too, it was fixed changing directory permissions.
If you came this far and you still have the error, this is how I fixed it:
Seems like you need at least PHP Version 5.3. If you have 5.2 you will get a warning (if you haven't disabled errors in PHP) from Line 250 in file UploadHandler.php. This will stop the headers for creating the file to be sent.
So disabling error messages should work, as mentioned several times above, but if you still want other errors to show, change Line 250 in UploadHandler.php to
@clearstatcache(true, $file_path);
The @ stopps the error to display. And as mentioned, its just a warning so your files will still process correctly. At least mine did :)
Another thing is debugging. It took me a while to figure out how to do it. The post of @jsheedy's explains it quite good:
You can also use google Chrome this way:
- open the developer tools by right clicking the page and selecting "Inspect Element"
- click network tab
- in the column labelled "name", click on /server/php
- in the submenu, click response
If you don't see any files there, reload the page while Chromes debugging tool is open and on the network tab. Its not always labelled /server/php though, in my case the filename was different, but you'll find it!
This is how I fixed it... I found an alternative to the "json_encode()" function here:
http://www.dzone.com/snippets/jsonencode-alternative-php-4
I added the function to UploadHandler.php prior to calling:
$json = json_encode($content);
After that the error disappeared because it is now able to read/parse the json response.
HTH
Hi,
I encounter the following error: "Error : SyntaxError : Unexpected token <" when I download a file 1.5MB This is a JSON error because it attempts to interpret an HTML error:
All directories have the rights ( 777 ) here is my phpinfo() parameters : memory_limit = 90M post_max_size = 8M upload_max_filesize = 40M
I do not understand where the problem is ... Can you help me?
thank you very much
This does the trick:
Add 'index.php' to line 21 of main.js:
url: 'server/php/index.php'
when i see the developer tools it shows, "statuscode:302 not modified",,how to solve it
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.