galetahub / ckeditor

Ckeditor 4.x integration gem for rails
https://ckeditor.com/ckeditor-4/
MIT License
2.23k stars 880 forks source link

Undefined message when uploading file #829

Closed pzupan closed 4 years ago

pzupan commented 5 years ago

I upgraded to 4.3.0 and the file upload is now not working. When I select an image and then click "Send to Server", I get an "undefined" message. There is no other error messages in the console or on the server. screenshot

When debugging on the server, I notice that the attributes of the asset model are blank when it is saved, and it fails validation.

   10:   def respond_with_asset(asset)
   11:     asset_response = Ckeditor::AssetResponse.new(asset, request)
   12: 
=> 13:     if asset.save
   14:       render asset_response.success(config.relative_url_root)
   15:     else
   16:       render asset_response.errors
   17:     end
(byebug) asset
#<Ckeditor::Picture id: nil, attachable_id: nil, attachable_type: nil, asset_type: "image", description: nil, sort_by: "", visible: false, data_file_name: nil, data_content_type: nil, data_file_size: nil, deleted_at: nil, created_at: nil, updated_at: nil, row_order: nil, data_fingerprint: nil>
(byebug) 
patricklindsay commented 5 years ago

Tested this and there does seem to be an issue with the 'Send it to the Server' button. However you can still upload images by clicking on 'Browse Server' within the image info tab.

Until this is fixed I'd recommend hiding the Upload tab. To do this add the following to your config.js

# app/assets/javascripts/ckeditor/config.js

config.removeDialogTabs = 'image:Upload';

Check here for more info on how to customise the editors

andikarekatias commented 5 years ago

i have the same problem. i've tried uploading images by clicking on 'Browse Server' within the image info tab, But the loading wont stop.

loading

i've tried too to drag and drop image, i got an "HTTP error occurred during file upload (error status: 422)." message.

drag n drop

hainminsoe commented 5 years ago

SOLVED

In my case , i was reinstalling image magic.

sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev libmagic-dev sudo apt-get install imagemagick

Everythins is OK right now, hope this help.

andikarekatias commented 5 years ago

My previus Version: ImageMagick 7.0.8-24 Q16 x64 2019-01-17 after update to Version: ImageMagick 7.0.8-25 Q16 x64 2019-01-28 still not work.

Tectract commented 5 years ago

Hi guys, I just set up CKEditor for the first time, fresh install following this tutorial:

https://richonrails.com/articles/getting-started-with-ckeditor

Neither "send it to server" from the image->upload tab nor "upload" button within the "ckeditor file manager" work, I cannot add ANY images to any articles, under this fresh ckeditor installation.

sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev libmagic-dev
sudo apt-get install imagemagick

This did NOT fix the isssue for me. Is there any workaround or known cause? Can I go back to a lower version of CKEditor and maybe it will work?

imagemagick (8:6.7.7.10-6ubuntu3.13) ckeditor (4.3.0) paperclip (6.1.0) rails 4.2.10 ruby 2.4.5

Tectract commented 5 years ago

here's some output from the rails logs that may be useful:

Started POST "/ckeditor/pictures?qqfile=Zion_national_park.jpg" for 127.0.0.1 at 2019-03-13 18:33:11 -0600 Processing by Ckeditor::PicturesController#create as / Parameters: {"qqfile"=>"Zion_national_park.jpg"} User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 2]] request at : http://localhost:3000/ckeditor/pictures?qqfile=Zion_national_park.jpg user_signed_in? : true [paperclip] Trying to link /tmp/95858f92392a00477aca698acc3443e7607517c720190313-12032-7l1x1i to /tmp/320d3652628d120cff0bd1d8a7d6079720190313-12032-1ux1i3s.jpg [paperclip] Trying to link /tmp/320d3652628d120cff0bd1d8a7d6079720190313-12032-1ux1i3s.jpg to /tmp/320d3652628d120cff0bd1d8a7d6079720190313-12032-1b03qb1.jpg Command :: file -b --mime '/tmp/320d3652628d120cff0bd1d8a7d6079720190313-12032-1b03qb1.jpg' (0.2ms) BEGIN [paperclip] Trying to link /tmp/320d3652628d120cff0bd1d8a7d6079720190313-12032-1ux1i3s.jpg to /tmp/320d3652628d120cff0bd1d8a7d6079720190313-12032-1uyzqpy.jpg Command :: file -b --mime '/tmp/320d3652628d120cff0bd1d8a7d6079720190313-12032-1uyzqpy.jpg' (0.2ms) ROLLBACK Completed 200 OK in 148ms (Views: 10.2ms | ActiveRecord: 1.3ms)

Tectract commented 5 years ago

the above response was when I tried the "upload" button. Here is the response when I try the "send it to server" button (below). Note they both end in ROLLBACK, oops!

Started POST "/ckeditor/pictures" for 127.0.0.1 at 2019-03->13 18:55:29 -0600 Processing by Ckeditor::PicturesController#create as / Parameters: {"upload"=>#<ActionDispatch::Http::UploadedFile:0x000000000df00228 @tempfile=#<Tempfile:/tmp/RackMultipart20190313-17968-mfm92q.jpg>, @original_filename="Zion_national_park.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"upload\"; filename=\"Zion_national_park.jpg\"\r\nContent-Type: image/jpeg\r\n">, "ckCsrfToken"=>"YZyfZUI10bhQWp67X12xBv25lbPW05OWL4qEMFY1"} User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 2]] request at : http://localhost:3000/ckeditor/pictures user_signed_in? : true (0.1ms) BEGIN (0.2ms) ROLLBACK Completed 200 OK in 9ms (Views: 0.3ms | ActiveRecord: 0.6ms)

Tectract commented 5 years ago

looks like for me the temporary work-around was to downgrade versions to gem 'ckeditor', '~> 4.1.3'

then I needed to rollback the paperclip migrate, redo it, forcing file overwrites...

Great plugin BTW hope you can nail this bug! Cheers~

jmchaves commented 5 years ago

I found a solution and it worked for me: https://stackoverflow.com/questions/54272909/ckeditor-upload-image-error-undefined-index-ckeditorfuncnum

jarongao commented 5 years ago

If you're using 'ckeditor' 4.3 gem with 4.11 JS lib, then you should use config.filebrowserUploadMethod = 'form'; if you had query params appended with an older version.

CKEditor 4.9 introduced "xhr" uploads and made it default. https://github.com/galetahub/ckeditor/blob/74c188c5bb7197c67197272f55951ca1c0864cda/vendor/assets/javascripts/ckeditor/CHANGES.md#ckeditor-49 ckeditor/ckeditor-dev#1365 ckeditor/ckeditor-dev@4e0866c

Tectract commented 5 years ago

Great catch guys. Can one of you test it and submit a PR bugfix?

r3cha commented 5 years ago

@jarongao Thanks, I see that problem was when you use newer version of Ckeditor like 4.9 and this version send filed as blob not form multipart and this is seems like bug in Ckeditor that change default behaviour of uploader and not fix default success request handler?

Tectract commented 5 years ago

I'm currently version-locked to a lower version of ckeditor because of the file upload not working bug. I'd say this is high priority, if anyone is actively working on this project.

r3cha commented 5 years ago

@Tectract You mean working on creditor? I'm not sure but think fix should be on Ckeditor like they change default behaviour of uploader but not did same for srcipt that handle this success request. I checkout his repos and they have a lot of) https://github.com/ckeditor for different frameworks.

Tectract commented 5 years ago

What I mean is that when I tried to install CKEditor, last month, I couldn't use the most recent version because image uploading is COMPLETELY BROKEN, so I am version-locked to a lower version where image loading still worked. As far as I'm concerned, the most recent release version is broken, and was released prematurely without proper testing, and needs critical care fixing, of this specific issue. Just my two cent.

jarongao commented 5 years ago

Our QA team has tested the new config setting in config.js and confirms that Image Uploading works as in version 4.2.4. I'll submit a PR to update the default config script.

Tectract commented 5 years ago

I'm currently locked on gem versino 4.1.3 because of this bug.

gem 'ckeditor', '~> 4.1.3'

Is there anything special I will need to do to upgrade to the latest version, once the "image uploading bug" is confirmed fixed?

kevinhq commented 5 years ago

This https://github.com/galetahub/ckeditor/pull/847/commits/ee605605bbd35b1f331a68e60435b6479d7dbac4 solved for me.

Using ckeditor 4.3.0. For those who did not want to upgrade to latest version (or were unable to), just apply that change on your own app/asssets/javascripts/ckeditor/config.js

jarongao commented 5 years ago

@Tectract, see previous comment https://github.com/galetahub/ckeditor/issues/829#issuecomment-495159213 that references my merged PR https://github.com/galetahub/ckeditor/commit/ee605605bbd35b1f331a68e60435b6479d7dbac4.

You can upgrade to gem version 4.3.0 and update your config.js with that line to have Image Uploads work.

Tectract commented 5 years ago

thank you I will test soon and report back if anything goes wrong :)

man1400 commented 5 years ago

I upgraded to 4.11.4 and the file upload is now not working. When I select an image and then click "Send to Server", I get an "undefined" message. There is no other error messages in the console or on the server.

image

jarongao commented 5 years ago

@man1400 https://github.com/galetahub/ckeditor/issues/829#issuecomment-490973673

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Tectract commented 5 years ago

I was able to upgrade to Rails 5.2.3 but only got CKEditor up to version 4.2.2 working. I was not able to get CKEditor working in Rails 5.2.3 at the latest version, and it had something to do with the change in the way the init routine is called, no longer included in config/application.rb?

Tectract commented 5 years ago

Also, I included in my app/assets/javascripts/ckeditor/config.js this line:

config.filebrowserUploadMethod = 'form';

not sure if that is actually required, but maybe it should be in the default config so we don't have to include it manually, or more of a note about that in the README?

Tectract commented 5 years ago

also, stalebot sucks. Issues should remain open until they are RESOLVED.

marvindpunongbayan commented 5 years ago

I encounter the same problem after upgrading my Ckeditor from 4.1.6 to 4.3.0.

And I solved the problem from my end without adding this line: config.filebrowserUploadMethod = 'form';

I just change this line from my OLD custom ckeditor/config: From: config.filebrowserImageUploadUrl = "/ckeditor/pictures?";

To: config.filebrowserImageUploadUrl = "/ckeditor/pictures?command=QuickUpload&type=Images";

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Tectract commented 4 years ago

stalebot is a virus

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

asecondwill commented 3 years ago

@marvindpunongbayan - worked for me - thanks.

ufukcicekdev commented 1 year ago

Hello, When I send to server I get undefined error. but the solutions written here did not work for me. . is there anyone who still has this problem and found a solution?