Forums

Image Resize and reCaptcha w/Optional Upload

datasavvy 13 May, 2010
Hi, I'm a newbie. Fairly new to PHP/Joomla as well, so forgive my terminology. I actually have two issues, and will be glad to post them separately, if you like.

I have created a form that uploads to a table I created, the updates that table with the current userid. I also have a file upload for an image and reCaptcha. The image resize plugin makes a thumbnail. It works fine when everything is entered correctly and a file selected to upload.

However, I get errors from the resize plugin when I test the form and do not upload an image. I need to make the upload optional, and put a default filename in the database without making a thumbnail.

Also, if I enter everything, but an incorrect reCaptcha code, the reCaptcha section does not republish. Instead I get the plugin text {ReCaptcha}

The site is on my local machine right now, but here is the code. Much thanks in advance.


<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_1" 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: :: anything</div></div><div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" style="width: 150px;">Description</label>
    <textarea class="cf_inputbox required" rows="2" id="text_0" title="" cols="50" name="ad_text"></textarea>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
<div class="tooltipdiv">Description :: Describe it</div>
  </div>
  <div class="cfclear"> </div>
</div>


<div  class="form_item"><div class="form_element cf_textbox"><label class="cf_label">When to do it</label><input class="cf_inputbox required" maxlength="11" size="11" id="text_5" name="time_to_do" 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">Ex: 1 hour, 3 days, 1 day</div></div><div class="clear"> </div>
</div>


<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Category</label>
<?php
$db =& JFactory::getDBO();
$query = 'SELECT * FROM ' . $db->nameQuote('#__my_categories');
$db->setQuery($query);

if ($cats =& $db->loadObjectList()) {
?>
  <select class="cf_inputbox validate-selection" id="select_1" size="1" title=""  name="mycatid">
<?php
  foreach ($cats as $cat) {

    echo "<option value='" . $cat->id . "'>" . $cat->title. "</option>";
  }
  echo "</select>";
} 
?>
</div>    
  </div>

<div class="clear"> </div>




<div class="form_item"><div class="form_element cf_fileupload"><label class="cf_label" style="width: 150px;">Upload a Photo (optional)</label><input class="cf_fileinput cf_inputbox" title="" size="20" id="file_0" name="img" type="file" /></div><div class="cfclear"> </div></div>

<div style="margin-left:30px;">Please enter the code below to submit your entry<br></div>
    <div style="margin-left:30px;">{ReCaptcha}</div> 
    

  <div class="cfclear"> </div>


<div  class="form_item"><div class="form_element cf_button"><input value="Submit You Ad" name="undefined" type="submit"></div><div class="clear"> </div></div>


Here is the On Submit Code:


<?php
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$userid=$user->id;
$query = "UPDATE `jos_mycomponent` SET created_by = $userid";
$db->setQuery($query);
$db->query();
?>


Here is the Error:


Warning: getimagesize(C:\xampp\htdocs\test-site25\components\com_mycomponent\uploads\) [function.getimagesize]: failed to open stream: No such file or directory in C:\xampp\htdocs\test-site25\components\com_chronocontact\plugins\cf_image_resize.php  on line 570

Warning: Division by zero in C:\xampp\htdocs\test-site25\components\com_chronocontact\plugins\cf_image_resize.php on line 594

Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\xampp\htdocs\test-site25\components\com_chronocontact\plugins\cf_image_resize.php on line 603

Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\test-site25\components\com_chronocontact\plugins\cf_image_resize.php on line 604

Warning: imagefilledrectangle() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\test-site25\components\com_chronocontact\plugins\cf_image_resize.php on line 606

Warning: imagealphablending() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\test-site25\components\com_chronocontact\plugins\cf_image_resize.php on line 607

Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\test-site25\components\com_chronocontact\plugins\cf_image_resize.php on line 610
GreyHead 15 May, 2010
Hi xlnce,

You are getting PHP 'Warnings' that something *might* be wrong - technically these aren't errors, they just mess up your page. And if the plugin were better coded they wouldn't appear.

Set your site Error Reporting to System Default (or possibly None) and they should disappear.

Don't know about the ReCaptcha problem - hard to tell without seeing the form. The ChronoForms ImageVerification may be more reliable here.

Bob
stefhillaire 24 May, 2010
Hi,
I have the same problem I think!
I found that come from the plug-in and only when we submit the form with out upload an image!....

Can somebody help me?

thanks
megana 09 Nov, 2011
Hi there,

I'm having the same problem with the image resize plugin. My upload field is optional, but if you leave it empty the form spits out all those errors when it can't find the file. Everything else still works, I just need to hide the 'errors'!

I tried setting Error Reporting to none, but it didn't work.

Any other suggestions?

Thanks,
-Megan
megana 09 Nov, 2011
Hi there,

I'm having the same problem with the image resize plugin. My upload field is optional, but if you leave it empty the form spits out all those errors when it can't find the file. Everything else still works, I just need to hide the 'errors'!

I tried setting Error Reporting to none, but it didn't work.

Any other suggestions?

Thanks,
-Megan
GreyHead 10 Nov, 2011
Hi Megan,

Edit your php.ini file to set the Error Reporting level there. In general a production site shouldn't be showing Notices and Warnings.

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