我已经无计可施了。我购买了 Real Ajax Uploader 源代码,它可以独立运行,但是当我尝试在 DIV 中显示它时,它搞砸了,只显示一个 DIV,其中的 JS 不起作用。没有收到错误消息,Firebug 也没有显示任何错误,所有 JS 和 CSS 似乎都按预期显示。
***更新
好的,我已经尝试了文档中的所有内容,但仍然没有更好的结果。
本地主机/index.php
<?php
error_reporting(E_ALL);
ob_start("ob_gzhandler");
include 'include/_abcde.php';
include 'include/_fghij.php';
include 'include/_klmno.php';
include 'include/_pqrs.php';
include 'include/_tuvwxyz.php';
include 'include/db.php';
include 'include/links.php';
include 'include/profilefunc.php';
include 'include/adodb-time.inc.php';
date_default_timezone_set('America/Edmonton');
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
if (isset($_SESSION['username'])){ echo"<title>Alberta XChange - Welcome ".$_SESSION['username']."</title>";}
else {echo"<title>Alberta XChange - Welcome</title>";}
?>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="Coffee's Creations">
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
<link rel="stylesheet" href="css/layout.css" type="text/css" />
<link rel="stylesheet" href="css/baseTheme/style.css" type="text/css" media="all" />
<script type="text/javascript" src="js/utility.js"></script>
<script type="text/javascript" src="js/myjs.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/ajaxupload.js"></script>
<script type="text/javascript">
SyntaxHighlighter.all({toolbar:false});
</script></head>
<body>
<?php
if(!empty($_POST['username'])&&!empty($_POST['user_pwd'])&&!empty($_POST['email'])){Register();}
if(!empty($_POST['usernamea'])&&!empty($_POST['passworda'])){Login();}
if (isset($_SESSION['username'])){LoggedIn();exit;}
else {LoginForm();}
?>
</body>
我已确认所有 JS 和 CSS 链接都有效。
localhost/include/_tuvwxyz.php(上传功能部分)
function Upload()
{
?>
<div id="uploader_div"></div>
<script type="text/javascript">
$('#uploader_div').ajaxupload({
url:'uploader/upload.php',
data:'asd=asd&qwe=123',
thumbHeight:200,
finish:function(files){
console.log(files);
}
});
</script>
<?php
}
localhost/uploader/upload.php 是upload.php 所在的位置。不会发布代码,因为它是原始的。但是,我无法判断 upload.php 是否正在打开,但我看不出它不会打开的原因。我唯一能想到的可能是因为 upload.php 是从 localhost/include 中的函数调用的,我需要将 url 设置为 ../uploader/upload.php 但即使那样也没有任何结果。
最佳答案
在文档中它说:
dropArea = *jQuery selector/DOM element*
Set the drag and drop area for files. Default the area is the initial container. Example can be set to dropArea:$('.class').
所以在你的情况下,我会试试这个:
dropArea: $('#drop_here')
关于javascript - 真正的 Ajax uploader 不会显示在 DIV 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20817226/