I am using a ecommerce extension for Joomla called digistore. Their website is foobla.com. I am able to create products, but when I try to upload images I get the error:
Invalid argument supplied for foreach() in /home/…/administrator/components/com_digistore/controllers/digistoreProducts.php on line 73
The php (starting with line 73) is:
[php] foreach( $files[‘name’] as $key => $file){
$ext_array = explode(".", $file);
$extension = $ext_array[count($ext_array)-1];
$extension = strtoupper($extension);
if($extension == “JPEG” || $extension == “JPG” || $extension == “PNG” || $extension == “GIF”){
if($files[‘error’][$key] == 0){
$uniqid = uniqid (rand (),true);
$filename = JFile::makeSafe($files[‘name’][$key]);
$filepath = JPath::clean($path_image . strtolower($uniqid.'_'.$files['name'][$key]));
if (!JFile::upload( $files['tmp_name'][$key], $filepath )) {
echo 'Cannot upload file to "' . $filepath . '"';
}
$db = JFactory::getDBO();
$sql = "select max(`order`) from `#__digistore_products_images` where `product_id`=".intval($product_id);
$db->setQuery($sql);
$db->query();
$max_order = $db->loadResult();
$new_order = intval($max_order) + 1;
echo "<div id='box".$uniqid."' style='padding-top:5px'>
<table>
<tr>
<td width=\"3%\">
<input type=\"checkbox\" name=\"selected_image[]\" value=\"\" />
</td>
<td width=\"4%\" align=\"center\">
<input id='def".$uniqid."' type='radio' name='default_image' value='".strtolower($uniqid.'_'.$files['name'][$key])."'/>
</td>
<td width=\"15%\" align=\"center\">
<a href='".ImageHelper::GetProductImageURL( strtolower($uniqid.'_'.$files['name'][$key]) )."' class='modal'>
<img src='".ImageHelper::GetProductThumbImageURL( strtolower($uniqid.'_'.$files['name'][$key]) )."'/>
</a>
</td>
<td width=\"12%\" align=\"center\">
<input type=\"text\" name=\"title[]\" value=\"\">
</td>
<td width=\"10%\" align=\"center\">
<span>
<a title=\"Move Up\" onclick=\"\" href=\"#reorder\"><img height=\"16\" width=\"16\" border=\"0\" alt=\"Move Up\" src=\"".JURI::root()."administrator/components/com_digistore/assets/images/uparrow.png"."\"></a>
</span>
<span> </span>
<input type=\"text\" name=\"order[]\" size=\"5\" value=\"".$new_order."\" class=\"text_area\" style=\"text-align: center;\">
</td>
<td>
<a href='javascript:void(0);' onclick='document.getElements(\"div[id=box".$uniqid."]\").each( function(el) { el.getParent().removeChild(el); });'>Delete</a>
</td>
<input type='hidden' name='prodimageshidden[]' value='".strtolower($uniqid.'_'.$files['name'][$key])."'/>
</div>";
}
}
else{
echo '<span style="color:red;">'.$file." ".JText::_("DIGI_UPLOAD_FALSE_IMAGE")."</span><br/>";
}
}[/php]
I have not changed the php file from the install. I am new to php, this is probably something simple. Let me know if you need more info.
Thanks!