$javascript2 = "";
$javascript2 .= "<script type=\"text/javascript\" src=\"" . JURI::base(). "components/com_datsogallery/libraries/uploader/source/mootools.js\"></script>\n";
$javascript2 .="<script type=\"text/javascript\" src=\"" . JURI::base(). "components/com_datsogallery/libraries/uploader/source/SwiffUploader.js\"></script>\n";
$javascript2 .="<script type=\"text/javascript\" src=\"" . JURI::base(). "components/com_datsogallery/libraries/uploader/source/FxProgressBar.js\"></script>\n";
$javascript2 .="<script type=\"text/javascript\" src=\"" . JURI::base(). "components/com_datsogallery/libraries/uploader/source/Lang.js\"></script>\n";
$javascript2 .="<script type=\"text/javascript\" src=\"" . JURI::base(). "components/com_datsogallery/libraries/uploader/source/FancyUpload2.js\"></script>\n";
$mainframe->addCustomHeadTag($javascript2);
echo "<table cellpadding='4' cellspacing='0' border='0' width='100%'>\n";
echo "<tr>\n";
echo "<td class='sectiontableheader'>\n" . _DG_NEW_PICTURE . "</td>\n";
echo "</tr>\n";
echo "</table>\n";
?>
<script type="text/javascript">
window.addEvent('domready', function() { // wait for the content
var up = new FancyUpload2($('demo-status'), $('demo-list'), { // options object
verbose: true,
data: {'us' : '<?php echo $user->username; ?>' , 'imgauthor' : document.getElementById('imgauthor').value , 'option' : '<?php echo $option; ?>' , 'gentitle' : document.getElementById('gentitle').value, 'catid' : document.getElementById('catid').value, 'gendesc' : document.getElementById('gendesc').value, 'access' : document.getElementById('access').value },
//
url: $('form-demo').action,
path: '<?php echo JURI::base(). "components/com_datsogallery/libraries/uploader/source/"; ?>SwiffUploader.swf',
typeFilter: {'Images (*.jpg, *.jpeg, *.gif, *.png)': '*.jpg; *.jpeg; *.gif; *.png' },
target: 'demo-browse',
onLoad: function() {
$('demo-status').removeClass('hide'); // we show the actual UI
$('demo-fallback').destroy(); // ... and hide the plain form
this.target.addEvents({
click: function() {
return false;
},
mouseenter: function() {
this.addClass('hover');
},
mouseleave: function() {
this.removeClass('hover');
this.blur();
},
mousedown: function() {
this.focus();
}
});
$('demo-clear').addEvent('click', function() {
up.remove(); // remove all files
var action = "../../modules/backend/clear_list.php/?str="+jQuery('#fotos').attr('value')+"";
sendRequest(action, "displ_none", getRequest);
jQuery('#fotos').attr('value',';');
jQuery('.miniatures').html('');
jQuery('.medium').attr('src','../../images/noimage.gif');
return false;
});
$('demo-upload').addEvent('click', function() {
up.start(); // start upload
return false;
});
},
onSelectFail: function(files) {
files.each(function(file) {
new Element('li', {
'class': 'validation-error',
html: file.validationErrorMessage || file.validationError,
title: MooTools.lang.get('FancyUpload', 'removeTitle'),
events: {
click: function() {
this.destroy();
}
}
}).inject(this.list, 'top');
}, this);
},
onFileSuccess: function(file, response) {
var json = new Hash(JSON.decode(response, true) || {});
if (json.get('status') == '1') {
file.element.addClass('file-success');
file.element.setStyle('background-image','url('+json.get('min')+')');
jQuery('#fotos').attr('value',jQuery('#fotos').attr('value')+';'+json.get('photo_name')+';');
jQuery('.miniatures').html( jQuery('.miniatures').html()+'<img src="../../upload/min-'+json.get('photo_name')+'">');
if(jQuery('.medium').attr('src','../../images/noimage.gif')) { jQuery('.medium').attr('src','../../upload/medium-'+json.get('photo_name')) };
file.info.set('html', '<strong>Фотография загружена</strong>');
} else {
file.element.addClass('file-failed');
file.info.set('html', '<strong>Произошла ошибка:</strong> ' + (json.get('error')? (json.get('error') + ' #' + json.get('code')) : response));/**/
}
},
onFail: function(error) {
switch (error) {
case 'hidden': // works after enabling the movie and clicking refresh
alert('To enable the embedded uploader, unblock it in your browser and refresh (see Adblock).');
break;
case 'blocked': // This no *full* fail, it works after the user clicks the button
alert('To enable the embedded uploader, enable the blocked Flash movie (see Flashblock).');
break;
case 'empty': // Oh oh, wrong path
alert('A required file was not found, please be patient and we fix this.');
break;
case 'flash': // no flash 9+ :(
alert('To enable the embedded uploader, install the latest Adobe Flash plugin.')
}
}
});
});
//]]></script>
<?php
echo "<div>\n<form action=\"". JURI::base(). "components/com_datsogallery/libraries/uploader/server/script.php\" method=\"post\" enctype=\"multipart/form-data\" id=\"form-demo\">\n ";
echo "<fieldset id=\"demo-fallback\">\n";
echo " <legend>"._DG_UPLOAD_STR."</legend>\n";
echo " <label for=\"demo-photoupload\">\n";
echo _DG_UPLOAD_STR.":\n";
echo " <input type=\"file\" name=\"Filedata\" />\n";
echo " </label>\n";
echo "</fieldset>\n";
echo "<div id=\"demo-status\" class=\"hide\">\n";
echo " <p>\n <strong>". _DG_UPLOAD_STR." <strong>\n";//<br /><br />".$user->username .",<br />"._DG_UPLOAD_HELP."<br /><br /><br />";
echo "<input type='hidden' name='id' value='" . @ $row->id . "' />";
echo " <a href=\"#\" id=\"demo-browse\">"._DG_UPLOAD_SEL."</a> |\n";
echo " <a href=\"#\" id=\"demo-clear\">"._DG_UPLOAD_CLR."</a> |\n";
//echo " <a href=\"#\" id=\"demo-upload\">"._DG_UPLOAD_UPLOAD."</a>\n";
echo " </p>\n";
echo " <div>\n";
echo " <strong class=\"overall-title\"></strong><br />\n";
echo " <img src=\"". JURI::base(). "components/com_datsogallery/libraries/uploader/assets/progress-bar/bar.gif\" class=\"progress overall-progress\" />\n";
echo " </div>\n";
echo " <div>\n";
echo " <strong class=\"current-title\"></strong><br />\n";
echo " <img src=\"". JURI::base(). "components/com_datsogallery/libraries/uploader/assets/progress-bar/bar.gif\" class=\"progress current-progress\" />\n";
echo " </div>\n";
echo " <div class=\"current-text\"></div>\n";
echo " <br /><input type='button' value='"._DG_UPLOAD."' class='button' id='demo-upload' />";
echo "</div>\n";
echo " <input name=\"fotos\" id=\"fotos\" type=\"hidden\" value=\";\">\n";
//echo "<input type='hidden' name='taskuser' value='".$user->username."'/>";
echo "<ul id=\"demo-list\"></ul>\n";
//
echo "</form>\n </div>\n";
echo "<div id=\"displ_none\"></div>\n";
<?php
define ( '_JEXEC', 1 );
define ( '_VALID_MOS', 1 );
define ( 'DS', DIRECTORY_SEPARATOR );
define ('JPATH_BASE', dirname (__FILE__).DS.'..' .DS.'..'.DS.'..'.DS.'..'.DS.'..');
Error_Reporting (E_ERROR);
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$folderGlobal=$_POST['pathsite'];
$result = array();
$result['time'] = date('r');
$result['addr'] = substr_replace(gethostbyaddr($_SERVER['REMOTE_ADDR']), '******', 0, 6);
$result['agent'] = $_SERVER['HTTP_USER_AGENT'];
if (count($_GET)) {
$result['get'] = $_GET;
}
if (count($_POST)) {
$result['post'] = $_POST;
}
if (count($_FILES)) {
$result['files'] = $_FILES;
}
// we kill an old file to keep the size small
if (file_exists('script.log') && filesize('script.log') > 102400) {
unlink('script.log');
}
$log = @fopen('script.log', 'a');
if ($log) {
fputs($log, print_r($result, true). "\n---\n");
fclose($log);
}
// Validation
$error = false;
if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
$error = 'Invalid Upload';
}
// Processing
if (mkdir (JPATH_BASE.'/userimport/'.$result['get'][us]))
{
}
move_uploaded_file($_FILES['Filedata']['tmp_name'],JPATH_BASE.'/userimport/'.$result['get'][us].'/'. $_FILES['Filedata']['name']);
$return['src'] = '/uploads/' . $_FILES['Filedata']['name'];
if ($error) {
$return = array(
'status' => '0',
'error' => $error
);
} else {
$return = array(
'status' => '1',
'name' => $_FILES['Filedata']['name']
);
// Our processing, we get a hash value from the file
//$return['hash'] = md5_file($_FILES['Filedata']['tmp_name']);
// ... and if available, we get image data
$info = @getimagesize($_FILES['Filedata']['tmp_name']);
if ($info) {
$return['width'] = $info[0];
$return['height'] = $info[1];
$return['mime'] = $info['mime'];
}
}
// Output
if (isset($_REQUEST['response']) && $_REQUEST['response'] == 'xml') {
// header('Content-type: text/xml');
// Really dirty, use DOM and CDATA section!
echo '<response>';
foreach ($return as $key => $value) {
echo "<$key><![CDATA[$value]]></$key>";
}
echo '</response>';
} else {
// header('Content-type: application/json');
echo json_encode($return);
}/**/
?>
пока не делал сам ресайз и переброску исходной имаги по папкам, но думаю тут проблем не будет....