Hi All
I've been asked to add the possibility to add images to my article submit form.
I've added the form element, the path for the action is set to /images/log (will it include JOOMLA_PATH before that automagically?)
How do I modify the article so that it will show the image? I had an idea that if I could add an <img src="image.jpg" alt="Image" height="200" width="200" /> in a custom code, but I'm not really sure how to do that properly
I too would like to accomplish this task. Has anyone been able to do it successfully? If so, please let us know.
Hi massimiliano1212,
At a guess you may not have set $name to the name of the uploaded image. It will be something like $form->data['input_name']
Bob
I've tried it put it seems not to work..Can you help me? I can pay for your work. Thank you very much.
here what i have written:
<?php
$uri = JFactory::getURI();
$img_tag = "<img src='{$uri->root()}images/nuovi-annunci/{$form->data['input_name']}' alt='image' style='height:200px; width:200px;' />";
?>
Hi massimiliano1212,
Yes, but you need to replace 'input_name' with the name of the file upload input in your form :-(
Bob
yes, yes.. i have tried it..i wrote:
<?php
$uri = JFactory::getURI();
$img_tag = "<img src='{$uri->root()}images/nuovi-annunci/{$form->data['input_file_14']}' alt='image' style='height:200px; width:200px;' />";
?>
where "input_file_14" is the field name of the file that the client upload.
but it doesn't work..what do i make wrong?
Hi massimiliano1212,
Please post a link to the form so I can take a quick look.
Bob
Hi massimiliano1212,
Sorry, my mistake, I can’t see anything when the form submits :-( Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
Bob
Hi GreyHead, have you seen my mail?
Do you need something else?
Hi massimiliano1212,
I took a look, the problem is that you are defining the variable but not doing anything with it. I added echo $img_url; to the code and that now displays the image.
You can also probably use just one Upload Files action rather than having separate ones.
Bob
I've tried it Greyhead but it seems it isn't work..I need that the image is uploaded in the body of the article but it doesn't do that..Do you have tried? It was working?, the image was uploaded in the body of the article that you submitted?
thank you
Hi GreyHead,
I have moved the custom Code action before the Submit Article action but it still doesn't work.
what it can be?
thank you
perfect..now it works! thank you Grey HEad
Hi leon101noel,
You have the Custom Code action before the Upload Files action so there is no file info to use in the link building.
Please try dragging the Custom Code down after the upload files action.
You've also used $name in the link without defining it. That probably needs to be $form->data['input_file_4'] to get the name of the uploaded file.
Bob
Have noticed one fatal flaw in my plan too lol, just made a simple form with the easy wizard, upload box and submit button, left all config to default and its not saving a file to components/com_choronoforms/uploads
Set the dir to 777 just to check still nothing, any ideas??
Hi leon101noel,
Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.
Note: if you are using the Easy Wizard you can turn on Debug on the Others tab.
Bob
Hi leon101noel,
I don't see any trace of an Upload Files action in the Debug output.
Bob
Yeah thats what i thought!
I added a file, i saw Chrome uploading it in its status bar but then nothing. This is probably my problem. Any specific server requirements etc??
Hi leon101noel,
Just to check, there is an Upload Files action in your form On Submit event? What settings does it have?
Bob
Hi leon101noel,
Mostly this is just a question of being careful and checking through step by step.
The image input in your form is called text_input_4 - but in the Custom Code you have used attachment_5.
The custom code adds the image link to introtext but in the Submit Article action you have content1 for the Full Text field and the Intro Text field is empty.
So, as far as I can see the result you get is correct for the way you have set it up.
Bob