It looks like you're new here. If you want to get involved, click one of these buttons!
// ImageUploader
$('#uploaderImages').Loader({
url: ['/dgpcms/public/uploadify/jquery.uploadify.v2.1.0.js', '/dgpcms/public/uploadify/swfobject.js', '/dgpcms/public/uploadify/uploadify.css'],
//debug: [true],
cache: [true],
success: function(target){
$(this).uploadify({
'uploader' : '../../uploadify/uploadify.swf',
'script' : '<?php echo $this->url(array(\'module\' => \'admin\', \'controller\' => \'images\', \'action\' => \'upload\')) ?>',
'scriptData': {'PHPSESSID': '<?php echo session_id();?>'},
'cancelImg' : '../../uploadify/cancel.png',
'auto' : true,
'folder' : '../../uploads/images/original/',
'multi' : true,
'sizeLimit' : '4194304',
'queueSizeLimit' : 50,
'buttonText': 'Select files',
'fileDesc' : '',
'fileExt' : '.jpg;*.jpeg;*.gif;*.png'
});
}
});
public function uploadAction()
{
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
// If the target directory isn't available, create it
if (!is_dir($targetPath)) {
mkdir($targetPath, 02775, true);
}
move_uploaded_file($tempFile, $targetFile);
switch ($_FILES['Filedata']['error'])
{
case 0:
$msg = \"No Error\"; // comment this out if you don't want a message to appear on success.
break;
case 1:
$msg = \"The file is bigger than this PHP installation allows\";
break;
case 2:
$msg = \"The file is bigger than this form allows\";
break;
case 3:
$msg = \"Only part of the file was uploaded\";
break;
case 4:
$msg = \"No file was uploaded\";
break;
case 6:
$msg = \"Missing a temporary folder\";
break;
case 7:
$msg = \"Failed to write file to disk\";
break;
case 8:
$msg = \"File upload stopped by extension\";
break;
default:
$msg = \"unknown error \".$_FILES['Filedata']['error'];
break;
}
if ($msg) {
$stringData = \"Error: \".$_FILES['Filedata']['error'].\" Error Info: \".$msg;
} else {
$stringData = \"1\"; // This is required for onComplete to fire on Mac OSX
}
echo $stringData;
}
}
protected function _initSession()
{
$sessName = \"PHPSESSID\";
$sessOptions = array('name' => $sessName);
// Flash has problems with cookies so we pass the PHPSESSID variable via get
// it'll be injected if it doesn't exist in _SERVER[\"HTTP_COOKIE\"] e.g. '; PHPSESSID=hdi5u83hfnu7ltlvp5q3bb53k4'
if ((stripos($_SERVER['REQUEST_URI'], '__tkn') !== false)
// &amp;&amp; preg_match('#^[a-z\d]{25,32}$#si', $_GET[$sessName])
&& preg_match('#__tkn/([a-z\d]{25,32})#si', $_SERVER['REQUEST_URI'], $matches)
&& (stripos($_SERVER[\"HTTP_COOKIE\"], $matches[1]) === false)) {
$sid = $matches[1];
$prefix = '';
if (!empty($_SERVER[\"HTTP_COOKIE\"])) {
$prefix = '; ';
}
$_SERVER[\"HTTP_COOKIE\"] .= $prefix . $sessName . '=' . $sid;
$_COOKIE[$sessName] = $sid;
Zend_Session::setId($sid);
}
Zend_Session::setOptions($sessOptions);
}
'script' : '<?php echo $this->url(array(\'module\' => \'admin\', \'controller\' => \'images\', \'action\' => \'upload\')) ?>',
Dudelisius said:
public function indexAction()
{
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
}
<script type=\"text/javascript\" src=\"<?php echo $this->baseUrl(); ?>/uploadify/jquery.uploadify.v2.1.0.min.js\"></script>
<script type=\"text/javascript\" src=\"<?php echo $this->baseUrl(); ?>/uploadify/swfobject.js\"></script>
<link rel=\"stylesheet\" type=\"text/css\" href=\"<?php echo $this->baseUrl(); ?>/uploadify/uploadify.css\" />
<script type=\"text/javascript\">// <![CDATA[
$(document).ready(function() {
$('#uploaderImages').uploadify({
'uploader' : '../../uploadify/uploadify.swf',
'script' : '<?php echo $this->url(array(\"controller\" => \"images\", \"action\" => \"index\")); ?>',
'cancelImg' : '../../uploadify/cancel.png',
'auto' : true,
'scriptData' : {'PHPSESSID': '<?php echo session_id();?>'},
'scriptAccess' : 'always',
'queueID' : 'fileQueue',
'folder' : '../../uploads/images/original/',
'multi' : true
});
});
// ]]></script>
<a href=\"javascript:$('#uploaderImages').uploadifyClearQueue();\"><?php echo $this->translate('Clear Queue'); ?></a>
<input type=\"file\" name=\"uploaderImages\" id=\"uploaderImages\" />
<div id=\"fileQueue\"></div>
<script type=\"text/javascript\" src=\"/dgpcms/public/uploadify/jquery.uploadify.v2.1.0.min.js\"></script>
<script type=\"text/javascript\" src=\"/dgpcms/public/uploadify/swfobject.js\"></script>
<link rel=\"stylesheet\" type=\"text/css\" href=\"/dgpcms/public/uploadify/uploadify.css\" />
<script type=\"text/javascript\">// <![CDATA[
$(document).ready(function() {
$('#uploaderImages').uploadify({
'uploader' : '../../uploadify/uploadify.swf',
'script' : '/dgpcms/public/admin/images/index',
'cancelImg' : '../../uploadify/cancel.png',
'auto' : true,
'scriptData' : {'PHPSESSID': 'il0900fifd0l3nte1q30658094'},
'scriptAccess' : 'always',
'queueID' : 'fileQueue',
'folder' : '../../uploads/images/original/',
'multi' : true
});
});
// ]]></script>
<script type=\"text/javascript\">// <![CDATA[
$(document).ready(function() {
$('#uploaderImages').uploadify({
'uploader' : '../../uploadify/uploadify.swf',
'script' : '<?php echo $this->baseUrl().'/admin/images/upload'; ?>',
'cancelImg' : '../../uploadify/cancel.png',
'scriptAccess' : 'always',
'queueID' : 'fileQueue',
'folder' : '../../uploads/images/original/',
'multi' : true,
'auto' : true,
});
});
// ]]></script>
public function uploadAction()
{
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
}
$this->acl->add(new Zend_Acl_Resource('upload'));