에 다시 포함하므로 업로드하는 동안 진행률 표시 줄을 보여주는 다중 업로드 가능성을 인터넷에서 검색했습니다. 저기에 많은 사람들이 있기 때문에 나는 내 필요에 맞는 것을 빨리 발견했다.PHP + jQuery Upload는 내 웹 사이트를
이제 업로드가 끝난 후 문제가 발생합니다. 업로드가 끝나자 마자 DIV에서 "파일 [번호] : 파일 이름 (크기)이 업로드되었습니다"상태가 업로드됩니다. 그러나 그것은 나에게 그 상태를 보여줄뿐만 아니라 내 웹 사이트 레이아웃을 복제본으로 다시 포함합니다.
누군가가 내가 하루 종일 거기에 앉아 및 오류 :(
이것은 HTML + 양식입니다 찾을 수 없습니다로이 나를 도울 수있는 사항 : jQuery를 파일이 필요
<div id="main">
<form id="pupload" action="upload.php" method="POST" enctype="multipart/form-data">
<fieldset class="tabulated">
<table id="down" class="bbcode_table" cellspacing="1">
<thead>
<tr class="Cnorm">
<td><input type="file" name="files[]" multiple="multiple" id="files"></td>
</tr>
</thead>
<tbody>
<tr class="Cmite">
<td><input id="submit" class="button1" type="submit" value="Upload"></td>
</tr>
</tbody>
</table>
</fieldset>
</form>
<div class="progress">
<div class="bar"></div>
<div class="percent">0%</div>
</div>
{msg}
<div id="status"></div>
<script>
jQuery(document).ready(function ($) {
"use strict";
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
$('form').ajaxForm({
beforeSend: function() {
status.empty();
var percentVal = '0%';
bar.width(percentVal);
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal);
percent.html(percentVal);
},
success: function(data, statusText, xhr) {
var percentVal = '100%';
bar.width(percentVal);
percent.html(percentVal);
status.html(xhr.responseText);
},
error: function(xhr, statusText, err) {
status.html(err || statusText);
}
});
});
</script>
</div>
을 . 웹 사이트 헤더에서 호출되는
이것에 PHP 코드입니다 :
<?php
defined ('main') or die ('no direct access');
$main_dir = 'include/downs/public-upload/';
// Upload dirs sorted by file types
$files = $main_dir.'files/';
$images = $main_dir.'images/';
$media = $main_dir.'media/';
$video = $main_dir.'video/';
// File extensions
$files_ext = array('apk','exe','doc','docx','docm','gadget','html','ini','pdf','php','rar','sh','txt','xlsx','zip');
$images_ext = array('gif','jpg','JPG','jpe','jpeg','JPEG','png','PNG');
$media_ext = array('mp3','ogg','wav');
$video_ext = array('avi','mp4','3gp');
$msg = '';
// Check rights first to make sure we can put the file in the directory
if (!is_writeable ($main_dir)) {
$msg = 'The folder "include/downs/<b>public-upload</b>/" requires WRITE (chmod 777) permission!!! Please set the WRITE (chmod 777) permission and reload the page.';
}
// Now we can upload our file
$tpl = new tpl ('admin/pupload/pupload_upload');
if ($_SERVER['REQUEST_METHOD'] == 'POST' and isset($_FILES['files']))
{
// loop all files
foreach ($_FILES['files']['name'] as $i => $name)
{
$pathinfo = pathinfo($name);
// if file not uploaded then skip it
if (!is_uploaded_file($_FILES['files']['tmp_name'][$i]))
continue;
// now we can move the uploaded files
// IMAGES
if (in_array($pathinfo['extension'], $images_ext)) {
if (move_uploaded_file($_FILES['files']['tmp_name'][$i], $images . $name))
{
$msg .= '<b>File ' .($i+1). ':</b> ' . $name . ' (' . niceBytes($_FILES['files']['size'][$i]) . ') <font color="#00FF00">successfully uploaded</font><br />';
} else {
$msg .= '<b>File ' .($i+1). ':</b> ' . $name . ' (' . niceBytes($_FILES['files']['size'][$i]) . ') <font color="#FF0000">not successfully uploaded</font><br />';
}
// FILES
} else if (in_array($pathinfo['extension'], $files_ext)) {
if (move_uploaded_file($_FILES['files']['tmp_name'][$i], $files . $name))
{
$msg .= '<b>File ' .($i+1). ':</b> ' . $name . ' (' . niceBytes($_FILES['files']['size'][$i]) . ') <font color="#00FF00">successfully uploaded</font><br />';
} else {
$msg .= '<b>File ' .($i+1). ':</b> ' . $name . ' (' . niceBytes($_FILES['files']['size'][$i]) . ') <font color="#FF0000">not successfully uploaded</font><br />';
}
// VIDEOS
} else if (in_array($pathinfo['extension'], $video_ext)) {
if (move_uploaded_file($_FILES['files']['tmp_name'][$i], $video . $name))
{
$msg .= '<b>File ' .($i+1). ':</b> ' . $name . ' (' . niceBytes($_FILES['files']['size'][$i]) . ') <font color="#00FF00">successfully uploaded</font><br />';
} else {
$msg .= '<b>File ' .($i+1). ':</b> ' . $name . ' (' . niceBytes($_FILES['files']['size'][$i]) . ') <font color="#FF0000">not successfully uploaded</font><br />';
}
// MEDIA
} else if (in_array($pathinfo['extension'], $media_ext)) {
if (move_uploaded_file($_FILES['files']['tmp_name'][$i], $media . $name))
{
$msg .= '<b>File ' .($i+1). ':</b> ' . $name . ' (' . niceBytes($_FILES['files']['size'][$i]) . ') <font color="#00FF00">successfully uploaded</font><br />';
} else {
$msg .= '<b>File ' .($i+1). ':</b> ' . $name . ' (' . niceBytes($_FILES['files']['size'][$i]) . ') <font color="#FF0000">not successfully uploaded</font><br />';
}
} else {
$msg .= '<b>File ' .($i+1). ':</b> ' . $name . ' (' . niceBytes($_FILES['files']['size'][$i]) . ') <font color="#FF0000">has an unsupported ending</font><br />';
}
}
}
$tpl->set_ar_out(array('msg' => $msg), 0);
?>
,536,913,632 10
파일이 폴더에 저장 될 때 업로드가 작동하고 "업로드 성공"메시지가 표시되지만 "include()"기능을 실행하는 것처럼 웹 사이트 레이아웃이 다시 포함됩니다.
나는 이것에 얻을 수 있던 어떤 도움든지를 위해 중대하다. 이 문제에 대한
어쩌면 $ ('status')를 지울 수 있습니까? status.html (""); –
따라서 status.html() 앞에 status.empty()를 넣으면 성공할 수 있습니다 : function? 나는 그것을 시도했지만 불행히도 아무것도 바뀌지 않았다 : ( –
아마도 xhr.responseText가 헤더를 반환하고있다.) upload.php에서 헤더를 확인한다. –