Forums

include image within article

ugly 30 Nov, 2009
I have produced a simple form that allows users to upload an article + article image. My form consists of two text entry fields for title and article text + an file upload box for an article to accompany the article.
I used the form wizard to generate the html code which looks like:


<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Click Me to Edit</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_0" name="text_0" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" style="width: 150px;">Click Me to Edit</label>
    <textarea class="cf_inputbox" rows="3" id="text_1" title="" cols="30" name="text_1"></textarea>
    
  </div>
  <div class="cfclear"> </div>
</div>
<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit" name="button_0" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>
<div class="form_item">
  <div class="form_element cf_fileupload">
    <label class="cf_label" style="width: 150px;">Click Me to Edit</label>
    <input class="cf_fileinput cf_inputbox" title="" size="20" id="file_9" name="file_9" type="file" />
    
  </div>
  <div class="cfclear"> </div>
</div>



My on submit code is as follows:


<p><span style="color: #0000ff;"><strong>Thank you for submitting your nominee entry.  We will review it shortly and if approved it will be published.</strong></span></p>
<p><span style="text-decoration: underline;"><strong>Admin.</strong></span></p>
<?php

$introtext = JRequest::getVar('text_1');

$introtext =  str_replace('{file_9}', '<p><img src="/home/welshart/public_html/newsimages/'.JRequest::getVar('file_9').'" target="_blank" ></p>', $introtext);





$_POST['catid'] = '8';
$_POST['id'] = '';
$_POST['sectionid'] = '3';
$_POST['state'] = '1';
$_POST['created'] = date("Y-m-d H:i:s");
$_POST['title'] = $_POST['text_0'];
$_POST['introtext'] = $introtext;

?>


This php block is hacked together from bits I have found on the forum the text is being parked in jos_content but the image is not being included. I would be most grateful if anybody could offer help with my image problem 😟
Max_admin 01 Dec, 2009
Hello,

I think the problem is here:

src="/home/welshart/public_html/newsimages/'.JRequest::getVar('file_9').'"


this is an absolute path, try to add the real live path for the images uploaded, live paths start with http://www....com/newsimages/..etc

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ugly 02 Dec, 2009
Thanks Max, tried this but still no luck. I just wonder if I'm missing a stage here. Should I be entering data in the upload tab and if so what? Once again thanks
ugly 02 Dec, 2009
I've realised my own error, I was not completing the fields upload tab. I assumed that you did not have to complete 'FieldName/Allowed Extensions/File Sizes' but the upload will not work if you do not complete this field info. Can any body confirm this is the case? I feel happy(as you do) that I've got this bit working.
GreyHead 06 Dec, 2009
Hi ugly,

Confirmed.

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