Closed bologer closed 8 years ago
i have the same trouble
I had the same problem, took me some time to figure it out. It's not clearly documented on the website, but what you need to do is, asuming that you use the php files provided by the creator:
You need to create the options:
var croppicHeaderOptions = {
uploadUrl:'img_save_to_file.php',
cropUrl:'img_crop_to_file.php'
}
The uploadUrl
is for the upload functionality where you select your file and the image is displayed in the 'cropbox'. The cropUrl
option is used for after you have cropped the image a new image is created and saved on your server.
If one of these urls is not set, you will not be able to upload or crop the image.
Hope this helped, took me some time to figure it out, but when I looked at the response I got back, it was just posting back to the page itself (so I received HTML) where the script expects a JSON response so it triggers this error.
I forgot to mention.
You can also use the processInline:true
option. This way you can ommit the option uploadUrl:'img_save_to_file.php',
Because image processing will be done on the client side.
But you still need the option cropUrl:'img_crop_to_file.php'
for actually saving the cropped image.
@erhankaradeniz thank you, I will try it today and tell you the result of it. Was waiting for someone who could explain it to me. Because could not figure it out "why it is not working?" For me it seemed that I was doing everything correct. The most annoying thing is that on the demo of the plugin everything works like a charm.
Have you manage to use this plugin?
@bologer Alright, I think it will work for you now after making the changes I have written. As I was stuck on the same problem.
After those changes I've written above the plugin works like a charm! No more errors, just need to rewrite the php files so everything is handled with imageMagic.
@erhankaradeniz tried to apply your changes now. It worked, as it did not show the error message in the console and now it does not show any messages - which is good.
Problem now is the following: without processInline: true
file img_save_to_file.php
does not upload file on the server as well as, cropping is no happening. No error shown as well. Also, after I click crop image, it returns the same state, such as "allows to choose another image and do the process over and over".
When I remove processInline: true
I get the same error as was in my first entry. And no cropping is allow, however image is uploaded successfully.
Do you know what can be the problem?
Can you share you Javascript code?
When you use processInline, you do NOT need the uploadUrl:'img_save_to_file.php',
but you should use 'cropUrl:'img_crop_to_file.php'' instead.
@erhankaradeniz This is JS:
var croppicOptions = {
// uploadUrl:'/img_save_to_file.php',
cropUrl:'/img_crop_to_file.php',
processInline: true
}
var cropperHeader = new Croppic('change-full-image', croppicOptions);
according to what you have said in the last reply
It looks like that should work. I don't see anything wrong there.
You said before that the previous changes worked, does that mean that the cropped image was saved successful? Why do you want to have the image processed inline?
@erhankaradeniz I want either:
Basically, the problem is just with cropping.
then I would just do this:
var croppicHeaderOptions = {
uploadUrl:'img_save_to_file.php',
cropUrl:'img_crop_to_file.php'
}
That should work. That's currently the config I'm using which works fine. If this doesnt work (if no image is uploaded, check in in your php files if the folders are correct. and have read/write permission.
If I just do this, I receive this error Uncaught SyntaxError: Unexpected token i
var croppicHeaderOptions = {
uploadUrl:'img_save_to_file.php',
cropUrl:'img_crop_to_file.php'
}
Have no ideas what is wrong with it.
Are you using the minified version? I also use the non-minified version for development.
Verstuurd vanaf mijn iPhone
Op 30 jan. 2016 om 16:11 heeft Alexander Teshabaev notifications@github.com het volgende geschreven:
If I just do this, I receive this error Uncaught SyntaxError: Unexpected token i
var croppicHeaderOptions = { uploadUrl:'img_save_to_file.php', cropUrl:'img_crop_to_file.php' } Have no ideas what is wrong with it.
— Reply to this email directly or view it on GitHub.
@erhankaradeniz minified
Can you try the not minified version? If you receive the same error, but the token is '<' then I think it's not calling the php file.
Verstuurd vanaf mijn iPhone
Op 30 jan. 2016 om 16:16 heeft Alexander Teshabaev notifications@github.com het volgende geschreven:
@erhankaradeniz minified
— Reply to this email directly or view it on GitHub.
@erhankaradeniz tried what you said, however still have the same issue (Uncaught SyntaxError: Unexpected token i
).
@erhankaradeniz all worked. problem was with paths in file img_crop_to_file.php (I used different path for saving images).
Receive this error when image is being cropped.
img_save_to_file.php
. - OK, image saves in the folder that I specified.Uncaught SyntaxError: Unexpected token i
- and of course image does not appear in the folder.PS. I use the latest version of all files of the plugin.
Please help.
Thank in advance.