http://digitarald.de/project/fancyupload/3-0/showcase/attach-a-file/
Хочу поставить такой аплоадер файлов на внутренние нужды.. всё подключил вроде по инструкции нипашет нихфига..
проверьте кто шарит.. правильно ли я сделал..
вотт мои действия и код :
в файле /administration/downloads.php
после..
require_once "../maincore.php";
require_once THEMES."templates/admin_header.php";
require_once INCLUDES."html_buttons_include.php";
include LOCALE.LOCALESET."admin/downloads.php";
я вставил:
add_to_head("<script type='text/javascript' src='../includes/jscripts/uploader/mootools.js'></script>");
add_to_head("<script type='text/javascript' src='../includes/jscripts/uploader/Fx.ProgressBar.js'></script>");
add_to_head("<script type='text/javascript' src='../includes/jscripts/uploader/Swiff.Uploader.js'></script>");
add_to_head("<script type='text/javascript' src='../includes/jscripts/uploader/FancyUpload3.Attach.js'></script>");
add_to_head("<script language='javascript' type='text/javascript'>
window.addEvent('domready', function() {
var up = new FancyUpload3.Attach('demo-list', '#demo-attach, #demo-attach-2', {
path: '../includes/uploader/Swiff.Uploader.swf',
url: '../includes/jscripts/uploader/script.php',
fileSizeMax: 2 * 1024 * 1024,
verbose: true,
onSelectFail: function(files) {
files.each(function(file) {
new Element('li', {
'class': 'file-invalid',
events: {
click: function() {
this.destroy();
}
}
}).adopt(
new Element('span', {html: file.validationErrorMessage || file.validationError})
).inject(this.list, 'bottom');
}, this);
},
onFileSuccess: function(file) {
new Element('input', {type: 'checkbox', 'checked': true}).inject(file.ui.element, 'top');
file.ui.element.highlight('#e6efc2');
},
onFileError: function(file) {
file.ui.cancel.set('html', 'Retry').removeEvents().addEvent('click', function() {
file.requeue();
return false;
});
new Element('span', {
html: file.errorMessage,
'class': 'file-error'
}).inject(file.ui.cancel, 'after');
},
onFileRequeue: function(file) {
file.ui.element.getElement('.file-error').destroy();
file.ui.cancel.set('html', 'Cancel').removeEvents().addEvent('click', function() {
file.remove();
return false;
});
this.start();
}
});
});
</script>");
Пробовал и через "echo" подключать...
Далее я вставил в этом же файле ниже где мне нужно между первым встречающимся..
opentable ();
closetable();
<a href='#' id='demo-attach'>Attach a file</a>
<ul id='demo-list'></ul>
<a href='#' id='demo-attach-2' style='display: none;'>Attach another file</a></div>
ну и наконец в .../mytheme/styles.css
#demo-list {
padding: 0;
list-style: none;
margin: 0;
}
#demo-list .file-invalid {
cursor: pointer;
color: #514721;
padding-left: 48px;
line-height: 24px;
background: url(../includes/uploader/error.png) no-repeat 24px 5px;
margin-bottom: 1px;
}
#demo-list .file-invalid span {
background-color: #fff6bf;
padding: 1px;
}
#demo-list .file {
line-height: 2em;
padding-left: 22px;
background: url(../includes/uploader/attach.png) no-repeat 1px 50%;
}
#demo-list .file span,
#demo-list .file a {
padding: 0 4px;
}
#demo-list .file .file-size {
color: #666;
}
#demo-list .file .file-error {
color: #8a1f11;
}
#demo-list .file .file-progress {
width: 125px;
height: 12px;
vertical-align: middle;
background-image: url(../includes/uploader/progress.gif);
}
Все файлы указанные по ссылкам лежат на своих местах..
вот ещё текст файла script.php
<?php
$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';
}
/**
* You would add more validation, checking image type or user rights.
*
if (!$error && $_FILES['Filedata']['size'] > 2 * 1024 * 1024)
{
$error = 'Please upload only files smaller than 2Mb!';
}
if (!$error && !($size = @getimagesize($_FILES['Filedata']['tmp_name']) ) )
{
$error = 'Please upload only images, no other files are supported.';
}
if (!$error && !in_array($size[2], array(1, 2, 3, 7, 8) ) )
{
$error = 'Please upload only images of type JPEG, GIF or PNG.';
}
if (!$error && ($size[0] < 25) || ($size[1] < 25))
{
$error = 'Please upload an image bigger than 25px.';
}
*/
// Processing
move_uploaded_file($_FILES['Filedata']['tmp_name'], '../files' . $_FILES['Filedata']['name']);
$return['src'] = '/files/' . $_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
/**
* Again, a demo case. We can switch here, for different showcases
* between different formats. You can also return plain data, like an URL
* or whatever you want.
*
* The Content-type headers are uncommented, since Flash doesn't care for them
* anyway. This way also the IFrame-based uploader sees the content.
*/
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);
}
?>
Флэш стоит.. 10-ка.. Может я что-то не так сделал.. подскажите пожлста=))
При нажатии на Attach a file ничего не происходит...
Если кто ставил на данную CMS этот аплоадер поделитесь опытом..B) |
|