Forums

Upload pics to article

relecule 11 Mar, 2009
Hi

Hope somebody can help me.. I have setup the forms components to submit to the Joomla articles.. Everything is working 100% and I used the Submit article template found on this website.. Now I would like to submit a URL in a normal text field and also upload about 3 images into the article.. Can some body explain how I can go about this.. This would be totally awesome if this can be done.. So I would like to have the title field, message field, url field and 3 image upload fields and this will submit to a new article in a category that I setup.

Thanks in advance..๐Ÿ™‚ ๐Ÿ˜ฒ
GreyHead 11 Mar, 2009
Hi relecule,

I seem to remember that this was discussed a few months back - but I don't remember the answer. Try searching here on submitcontent and see if you can find it.

Bob
relecule 12 Mar, 2009
Ok I managed to find something here and I am now able to upload pics to an article. My problem is that when a user submits text to an article and adds spaces into the article, the spaces/ paragraphs do not show up. Everything displays as one line. also another thing is when we try to add links through the text editor it strips the tags away.

Here is my code

<?php
    $introtext = JRequest::getVar('introtext');

            $introtext =  str_replace('{image1}', '<p><img src="components/com_chronocontact/uploads/showandtell/'.JRequest::getVar('file_1').'" target="_blank" ></p>', $introtext);


So I think the str_replace is removing all html tags.
Max_admin 12 Mar, 2009
Hi relecule,

the spaces/ paragraphs do not show up



show me the onsubmit code of the form

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
relecule 12 Mar, 2009
Here you go...

 <?php
    $introtext = JRequest::getVar('introtext');

            $introtext =  str_replace('{image1}', '<p><img style="max-width:500px;border:5px solid #eeeeee;" src="components/com_chronocontact/uploads/showandtell/'.JRequest::getVar('file_1').'" target="_blank" ></p>', $introtext);

       

            $introtext = str_replace('{image2}', '<p><img style="max-width:500px;border:5px solid #eeeeee;" src="components/com_chronocontact/uploads/showandtell/'.JRequest::getVar('file_2').'" target="_blank" ></a></p>', $introtext);
           
    JRequest::setVar('introtext', $introtext);

$_POST['catid'] = '20';
$_POST['id'] = '';
$_POST['sectionid'] = '5';
$_POST['state'] = '1';
$_POST['created'] = date("Y-m-d H:i:s");

    ?>


I also noticed that if a user does not submit the 2nd image then a nofile image will display in IE.. Anyway around this?
relecule 13 Mar, 2009
I have posted the code above.. Any luck with this one..
Max_admin 13 Mar, 2009
try this:


$mydata = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
 $introtext =$mydata['introtext'];



cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
relecule 16 Mar, 2009
Great that worked well.. Just one more problem. If I upload only one image then I get a broken image displaying in IE for the 2nd image.. Is there a way around this..
GreyHead 16 Mar, 2009
Hi relecule,

When you do the string replaces check if there is an image loaded and if not just remove the placeholder.

Bob
relecule 16 Mar, 2009
Thanks for the response.. Ok, I am not so clued up on PHP as I am still learning. How will I go about this..
relecule 16 Mar, 2009
I noticed another problem when I tried to add a article via Internet Explorer.. I noticed that in the text editor the {image1} and {image2} is displaying and I have set the span to visibilty: hidden.. Has anybody seen this before..

Any help will be much appreciated..
relecule 16 Mar, 2009
Ok I managed to figure it out.. Woo hoo.. Here is my code for people that need to do same.... This works in all browsers. And thanks to the guys that helped..

The code below will do the following

Submit to a specified category
Write the article
upload 2 pic's and submit to an article

this is the HTML code

<div  class="form_item"></div>

<br /><br />

<div  class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Title:</label><input class="cf_inputbox required" maxlength="150" size="30" id="text_5" name="title" type="text"><a onclick="return false;" class="tooltiplink"><img  src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" width="16" border="0" height="16"></a><div  class="tooltipdiv">Title: :: Your story title please!</div></div><div class="clear">ย </div></div><div  class="form_item"><div class="form_element cf_textarea" style="width:600px;"><label class="cf_label">Show and tell:</label><br />
<table border="0" cellpadding="5" width="900px" >
<tr>
<td>
<textarea style=float: left; class="cf_inputbox required" rows="10" id="introtext" cols="50" name="introtext"></textarea>
</td>
<td>
<div class="Youtube"><strong>Please type in your ideas or add videos from YOUTUBE. Example Code:</strong> <br />
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Ll2kajMH2u0&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Ll2kajMH2u0&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
</div>
<div class="clear">ย </div>
</td>
</tr>
</table>
<?php
global $database, $my;
$query = "SELECT id FROM #__users WHERE id = '".$my->id."'";
$database->setQuery( $query );
$userdata = $database->loadObject($userdata);
?>
</div><div class="clear">ย </div></div><div  class="form_item"><div class="form_element cf_textbox"><input class="cf_inputbox" maxlength="15" size="30" id="text_7" name="created_by" readonly="readonly" value="<?php echo $userdata->id; ?>" type="hidden"></div><div class="clear">ย </div></div>

<div  class="form_item">
<label class="cf_label">Image 1:</label>
    <input class="cf_inputbox" size="20" id="file_1" name="file_1" type="file">
</div><div class="clear">ย </div>
<div  class="form_item">
<label class="cf_label">Image 2:</label>
    <input class="cf_inputbox" size="20" id="file_2" name="file_2" type="file">
</div><div class="clear">ย </div>
<div  class="form_item"><div class="form_element cf_captcha"><label class="cf_label">Enter code as shown</label><span>{imageverification}</span></div><div class="clear">ย </div></div><div  class="form_item"><div class="form_element cf_button"><input class="button" value="Submit" name="undefined" type="submit"><input class="button" type=button value="Back" onClick="history.go(-1)"></div><div class="clear">ย </div></div>


This is the on submit code after sending email



<p><span style="color: #0000ff;"><strong>Thank you for submitting your article!</strong><br /><br /><a href="cm">Go back to my profile</a></span></p>

 <?php  
 
$fulltext_template = "<br /><br /><strong>{file_1}</strong><br /><br /><strong>{file_2}</strong>";
$fulltext_template = str_replace("{file_1}", '<p><img style="max-width:500px;border:5px solid #eeeeee;" src="/components/com_chronocontact/uploads/showandtell/'.JRequest::getVar("file_1").'" target="_blank" ></p>', $fulltext_template);
$fulltext_template = str_replace("{file_2}", '<p><img style="max-width:500px;border:5px solid #eeeeee;" src=/components/com_chronocontact/uploads/showandtell/'.JRequest::getVar("file_2").'" target="_blank" ></p>', $fulltext_template);
JRequest::setVar("fulltext", $fulltext_template);

$_POST['catid'] = '20';
$_POST['id'] = '';
$_POST['sectionid'] = '5';
$_POST['state'] = '1';
$_POST['created'] = date("Y-m-d H:i:s");

    ?>



O and by the way check this youtube video.. damn funny....

http://www.youtube.com/watch?v=Ll2kajMH2u0
zeroonea 17 Mar, 2009
hi, i got a error

Fatal error: Call to a member function setQuery() on a non-object in G:\xampplite\htdocs\gamezone\components\com_chronocontact\chronocontact.html.php(352) : eval()'d code on line 22

seem $database not exists in this context ๐Ÿคจ
GreyHead 17 Mar, 2009
Hi zeroonea,

That's Joomla 1.0 code; for Joomla 1.5 replace this line
global $database, $my;
with this
$database =& JFactory::getDBO();
$my =& JFactory::getUser();
There may be other changes needed, I haven't checked any further.

Bob
tokenring 05 Apr, 2009
what was the code in this thread that showed how to attach an attachment (image) to a standard joomla article.

Aaron
tokenring 07 Apr, 2009
okay... I'll try it tonight!!!

:-)
psamim 26 May, 2009
Thank you!
Can we make a form like this but it can upload every kind of attachments, not just images?
tokenring 29 May, 2009
I got to get on this quickly... cuz I'm having to manually add the content that I want to the users to submit during the completion of a form. So I guess you can have the form add images, text, urls... etc?

Where should I go to learn PHP? I know there is a lot of threads/forums out there, but is there one that you guys would recommend?


Thanks,

Aaron
GreyHead 30 May, 2009
Hi Aaron,

W3Schools is pretty good and free, Zend are the experts but I'm not sure that have any free classes.

Bob
relecule 11 Jun, 2009
Hi, I posted this a while ago, but I would like to enhance the features of my website. It works beautifully but now I want users to edit the articles in the same way that they submitted. So if they posted then only they will be able to edit the article but it needs to display the same fields as in the submit form. How would I go about this. Can anybody shed some light on this one.. :?
GreyHead 11 Jun, 2009
Hi relecule,

As it happens I've been thinking about this problem this week.

The answer that I'm going to try is to save the info from the original form in a separate table from jos_contents (as well as adding it to jos_content). That way if the user edits then we can re-load their original data in to a ChronoForm then when they submit rebuild the article and update that and save the component parts for future editing.

Bob
This topic is locked and no more replies can be posted.