Eсть самописный комопнет под 1.5.x. комопнент доски объявления. всё хорошо работате, вот только.
при заполнени формы для объявления там есть фозможноть загрузит фото, так вот в OPERA и в FF фото грузится и на сервер передаётся файлы и в базе в поле объявления прописывается имя фото.
А вот если через IE подавать объявения, тогда ни фото не переаётся на сервер (файл) ни в базу не идёт запрос на поле фото... - а объявления просто добавляется без фото
Вчём по ваему может быть причина . -
Мне говрили что JS возожно, но я вроде отключила всё JS файлы которые подключались, но смысла не было.
Думаю проблема в функции т.к. IE гулчит с функциями по сравнению с OPER и FF.
\components\com_ads\views\as_adsaddsrv\tmpl\default.php<?php
defined('_JEXEC') or die( 'Restricted access' );
$model = $this->model;
?>
<form name="ads_addsrv" onsubmit="return validForm();" action="index.php?option=com_as_ads" method="post" enctype="multipart/form-data">
<table cellspacing="0" cellpadding="0" border="0" class="ads_add">
<tbody>
<tr>
<td><small><font color="red">*</font></small> Доп инфо</td>
<td nowrap="nowrap">
<textarea name="dop_info" cols="50" rows="6" class="inputbox"></textarea>
</td>
</tr>
<tr>
<td nowrap="nowrap">Фото</td>
<td>
<input type="file" name="adsphoto[]" value="" class="inputbox" /><br />
<input type="file" name="adsphoto[]" value="" class="inputbox" /><br />
<input type="file" name="adsphoto[]" value="" class="inputbox" /><br />
<input type="file" name="adsphoto[]" value="" class="inputbox" /><br />
<input type="file" name="adsphoto[]" value="" class="inputbox" />
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="ajax_file" value="<?php echo JURI::base().'administrator/components/com_as_ads/ajax.php'; ?>" />
<input type="hidden" name="option" value="com_as_ads" />
<input type="hidden" name="task" value="ads_addsrv" />
<br />
<center><input type="submit" name="ads_submit" class="ads_submit" value="Добавить" /></center>
</form>
\components\com_ads\views\as_adsaddsrv\view.html.php<?php
defined('_JEXEC') or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
class As_AdsViewAs_AdsAddSrv extends JView {
function display($tpl = null) {
global $mainframe, $option;
JHTML::_('stylesheet', 'as_adsaddsrv.css', 'components/com_as_ads/css/');
$user = &JFactory::getUser();
$uri =& JFactory::getURI();
$model = &$this->getModel('as_adsaddsrv');
$document =& JFactory::getDocument();
$document =& JFactory::getDocument(); $this->assignRef('document', $document);
$conf =& JFactory::getConfig();
$siteName = $conf->getValue('config.sitename');
$document->setTitle($siteName.' - Добавить объявление');
$this->assignRef('model', $model);
parent::display();
}
}
?>
\components\com_ads\controller.php<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.controller' );
class As_AdsController extends JController {
function display() {
$document =& JFactory::getDocument();
$viewName = JRequest::getCmd('view', 'as_ads');
$viewType = $document->getType();
$view = &$this->getView($viewName, $viewType);
$model = &$this->getModel( $viewName );
if (!JError::isError( $model )) {
$view->setModel( $model, true );
}
$view->display();
}
function ads_addsrv() {
$model =& $this->getModel( 'as_adsaddsrv' );
$post = JRequest::get( 'post' );
$files = JRequest::get( 'files' );
$images = $files['adsphoto'];
$imgCount = 1;
$obj = new stdClass();
$obj->publish = 0;
$obj->ads_view = 0;
$obj->date_start = date('Y-m-d');
$obj->date_end = date('Y-m-d', strtotime('+365 day'));
$obj->tip_servisa = $post['tip_servisa'];
$obj->dop_info = $post['dop_info'];
$imgNames = $model->loadImages($images);
if ($imgNames) {
foreach ($imgNames AS $img) {
eval('$obj->photo'.$imgCount.' = $img;');
$imgCount++;
}
}
if ($id = $model->adsAdd($obj)) {
$this->setRedirect( 'index.php?option=com_as_ads&view=as_adsmessage&adsid='.$id );
//$this->setMessage( JText::_('Ваше объявление добавленно с ID '.$id) );
} else {
$this->setRedirect( 'index.php?option=com_as_ads&view=as_adslistsrv' );
JError::raiseWarning(500, JText::_('Error'));
}
}
?>
\components\com_ads\models\as_adsaddsrv.php<?php
defined('_JEXEC') or die( 'Restricted access' );
jimport('joomla.application.component.model');
class As_AdsModelAs_AdsAddSrv extends JModel {
function __construct() {
parent::__construct();
}
function adsAdd($data) {
$db = &JFactory::getDBO();
if (!is_object($data))
return false;
if ($db->insertObject('#__as_ads_serv', $data))
return $db->insertid();
else
return false;
}
function loadImages($images) {
$imgTypes = array('image/jpeg', 'image/gif', 'image/png');
$imgList = array();
$imgName = '';
for ($i=0; $i<count($images['name']); $i++) {
if (in_array(strtolower($images['type'][$i]), $imgTypes)) {
$imgName = md5($images['name'][$i].mt_rand()).'.'.strtolower(array_pop(explode('.', $images['name'][$i])));
if (copy($images['tmp_name'][$i], AS_ADS_IMG_PATH.$imgName)) {
$imgList[] = $this->resizeImage(AS_ADS_IMG_PATH.$imgName, AS_ADS_IMG_PATH.$imgName);
}
}
}
if (!count($imgList))
return false;
else
return $imgList;
}
function resizeImage($imgFromPath, $imgToPath, $imgNWidth=400) {
if (!is_file($imgFromPath))
return false;
$imgExt = strtolower($this->getImageType($imgFromPath));
eval('$imgFrom = imagecreatefrom'.$imgExt.'("$imgFromPath");');
$imgFromX = imagesx($imgFrom);
$imgFromY = imagesy($imgFrom);
if ($imgFromX > $imgNWidth) {
$imgNHeight = round($imgNWidth * $imgFromY / $imgFromX);
$imgTo = imagecreatetruecolor($imgNWidth, $imgNHeight);
imagecopyresized($imgTo, $imgFrom, 0, 0, 0, 0, $imgNWidth, $imgNHeight, $imgFromX, $imgFromY);
imagejpeg($imgTo, $imgToPath);
imagedestroy($imgTo);
}
imagedestroy($imgFrom);
$this->addWatermark($imgToPath, AS_ADS_IMG_PATH.'watermark.png');
return basename($imgToPath);
}
function addWatermark($imgPath, $watermarkPath) {
if (!file_exists($imgPath) || !file_exists($watermarkPath)) {
return false;
}
$typeImg = $this->getImageType($imgPath);
eval('$img = imagecreatefrom'.$typeImg.'($imgPath);');
$wm = imagecreatefrompng($watermarkPath);
if (!$img || !$wm)
return false;
$img_w = $img_h = $wm_w = $wm_h = $img_x = $img_y = 0;
$img_w = imagesx($img);
$img_h = imagesy($img);
$wm_w = $wm_w_t = imagesx($wm);
$wm_h = $wm_h_t = imagesy($wm);
if (($wm_w + 10) >= $img_w) {
$wm_w_t = round($wm_w - 10 - ($wm_w - $img_w));
$wm_h_t = round($wm_h * $wm_w_t / $wm_w);
}
if (($wm_h + 10) >= $img_h) {
$wm_h_t = round($wm_h - 10 - ($wm_h - $img_h));
$wm_w_t = round($wm_w * $wm_h_t / $wm_h);
}
$img_x = $img_w-$wm_w_t-10;
$img_y = $img_h-$wm_h_t-10;
imagecopyresized($img, $wm, $img_x, $img_y, 0, 0, $wm_w_t, $wm_h_t, $wm_w, $wm_h);
eval('image'.$typeImg.'($img, $imgPath);');
imagedestroy($img);
imagedestroy($wm);
return true;
}
function getImageType($imgPath) {
$type = getimagesize($imgPath);
if (!$type)
return false;
switch ($type[2]) {
case 1:
return 'gif';
break;
case 2:
return 'jpeg';
break;
case 3:
return 'png';
break;
}
}
}
?>
Кокой кусок кода с кокого файла вам предостаивть ещё?
