Php to compress image

iwr 08 Jun, 2020
Hi ,
I have a php script that compresses an image on upload. It works fine as a standalone script outside chronoforms but I'm trying to create a form where it would do the same thing. So I have a simple form with (in load) views, a file field and a submit button. In the submit Action section I have the php script to compress and upload the compressed image. which works until I click submit then I get the error:

"Warning: imagejpeg(components/com_chronoforms6/chronoforms/components/com_chronoforms6/chronoforms/uploads/myimage.png):
failed to open stream: No such file or directory in /home/www/mywebsite/libraries/cegcore2/admin/extensions/chronofc/functions/php/php_output.php(6)
: eval()'d code on line 26"

I realise the file path must be wrong, but not sure how to correct it? I've tried using $path but no luck. My upload path is "// File upload path
$uploadPath = "components/com_chronoforms6/chronoforms/components/com_chronoforms6/chronoforms/uploads/";

What should the path be?

Ian
Max_admin 08 Jun, 2020
Hi Ian,

The path will be like this:
$this->get("upload_action_name.field_name.path");
You need to use the correct upload_action_name and field_name
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
iwr 08 Jun, 2020
Hi Max,

Thank you, that worked and got rid of the error message but the image doesn't upload face-meh-blank

$uploadPath = $this->get("submit.image.components/com_chronoforms6/chronoforms/components/com_chronoforms6/chronoforms/uploads/uploads");

Ian
healyhatman 09 Jun, 2020
Replace "submit" with the name of the upload file action. Unless you literally called it "submit"
Replace the giant path you have with the word "path"
Max_admin 09 Jun, 2020
the code I posted, after you update it with the variables needed, should give you the uploaded image path, which can be used in your PHP code.

Please post the debug data you get after submitting the form!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.