近日小弟在研究swfupload时遇到了个棘手的问题,恳请哪们大虾赐教。以下是代码:
<?php
session_start();
$_SESSION["file_info"] = array();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>SWFUpload Demos - Application Demo</title>
<link href="../css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../swfupload/swfupload.js"></script>
<script type="text/javascript" src="js/handlers.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
var swfu;
window.onload = function () {
swfu = new SWFUpload({
// Backend Settings
upload_url: "upload.php",
post_params: {"PHPSESSID": "<?php echo session_id(); ?>"},
// File Upload Settings
file_size_limit : "2 MB", // 2MB
file_types : "*.jpg;*.gif;*,png",
file_types_description : "JPG Images",
file_upload_limit : "4",
// Event Handler Settings - these functions as defined in Handlers.js
// The handlers are not part of SWFUpload but are part of my website and control how
// my website reacts to the SWFUpload events.
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete, // Button Settings
button_image_url : "images/SmallSpyGlassWithTransperancy_17x18.png",
button_placeholder_id : "spanButtonPlaceholder",
button_width: 180,
button_height: 18,
button_text : '<span class="button">Select Images <span class="buttonSmall">(2 MB Max)</span></span>',
button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }',
button_text_top_padding: 0,
button_text_left_padding: 18,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,
button_action : SWFUpload.BUTTON_ACTION.SELECT_FILES,
// Flash Settings
flash_url : "../swfupload/swfupload.swf", custom_settings : {
upload_target : "divFileProgressContainer"
},
// Debug Settings
debug: true
});
//动态传递参数
function setPost(){
var aid = document.getElementById('picgid').value; //相册ID
var uid = document.getElementById('uid').value; //上传照片用户ID
swfu.addPostParam("gid", gid);
swfu.addPostParam("uid", uid);//动态修改SWFUpload初始化设置中的post_params属性,其中所有的值都将被覆盖。
}
};
</script>
</head>
<body>
<div id="header">
<h1 id="logo"><a href="../">SWFUpload</a></h1>
<div id="version">v2.2.0</div>
</div>
<div id="content">
<h2>Application Demo</h2>
<p>This demo shows how SWFUpload can behave like an AJAX application. Images are uploaded by SWFUpload then some JavaScript is used to display the thumbnails without reloading the page.</p>
<?php
if( !function_exists("imagecopyresampled") ){
?>
<div class="message">
<h4><strong>Error:</strong> </h4>
<p>Application Demo requires GD Library to be installed on your system.</p>
<p>Usually you only have to uncomment <code>;extension=php_gd2.dll</code> by removing the semicolon <code>extension=php_gd2.dll</code> and making sure your extension_dir is pointing in the right place. <code>extension_dir = "c:\php\extensions"</code> in your php.ini file. For further reading please consult the <a href="http://ca3.php.net/manual/en/image.setup.php">PHP manual</a></p>
</div>
<?php
} else {
?>
<form>
<div style="display: inline; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;">
<span id="spanButtonPlaceholder"></span>
</div>
</form>
<?php
}
?>
<form action = "process.php" method="post" enctype="multipart/form-data">
<div id="divFileProgressContainer" style="height: 75px;"></div>
<div id="thumbnails"></div>
<input type="submit" name="submit" />
</form>
</div>
</body>
</html>我想达到上传图片的效果,可是点击上传后没有得到$_FILES效果,请问:怎样才能够使表单通过flash上传完图片后再点击提交按钮,然后可能得到$_FILES的值呢?
<?php
session_start();
$_SESSION["file_info"] = array();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>SWFUpload Demos - Application Demo</title>
<link href="../css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../swfupload/swfupload.js"></script>
<script type="text/javascript" src="js/handlers.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
var swfu;
window.onload = function () {
swfu = new SWFUpload({
// Backend Settings
upload_url: "upload.php",
post_params: {"PHPSESSID": "<?php echo session_id(); ?>"},
// File Upload Settings
file_size_limit : "2 MB", // 2MB
file_types : "*.jpg;*.gif;*,png",
file_types_description : "JPG Images",
file_upload_limit : "4",
// Event Handler Settings - these functions as defined in Handlers.js
// The handlers are not part of SWFUpload but are part of my website and control how
// my website reacts to the SWFUpload events.
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete, // Button Settings
button_image_url : "images/SmallSpyGlassWithTransperancy_17x18.png",
button_placeholder_id : "spanButtonPlaceholder",
button_width: 180,
button_height: 18,
button_text : '<span class="button">Select Images <span class="buttonSmall">(2 MB Max)</span></span>',
button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }',
button_text_top_padding: 0,
button_text_left_padding: 18,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,
button_action : SWFUpload.BUTTON_ACTION.SELECT_FILES,
// Flash Settings
flash_url : "../swfupload/swfupload.swf", custom_settings : {
upload_target : "divFileProgressContainer"
},
// Debug Settings
debug: true
});
//动态传递参数
function setPost(){
var aid = document.getElementById('picgid').value; //相册ID
var uid = document.getElementById('uid').value; //上传照片用户ID
swfu.addPostParam("gid", gid);
swfu.addPostParam("uid", uid);//动态修改SWFUpload初始化设置中的post_params属性,其中所有的值都将被覆盖。
}
};
</script>
</head>
<body>
<div id="header">
<h1 id="logo"><a href="../">SWFUpload</a></h1>
<div id="version">v2.2.0</div>
</div>
<div id="content">
<h2>Application Demo</h2>
<p>This demo shows how SWFUpload can behave like an AJAX application. Images are uploaded by SWFUpload then some JavaScript is used to display the thumbnails without reloading the page.</p>
<?php
if( !function_exists("imagecopyresampled") ){
?>
<div class="message">
<h4><strong>Error:</strong> </h4>
<p>Application Demo requires GD Library to be installed on your system.</p>
<p>Usually you only have to uncomment <code>;extension=php_gd2.dll</code> by removing the semicolon <code>extension=php_gd2.dll</code> and making sure your extension_dir is pointing in the right place. <code>extension_dir = "c:\php\extensions"</code> in your php.ini file. For further reading please consult the <a href="http://ca3.php.net/manual/en/image.setup.php">PHP manual</a></p>
</div>
<?php
} else {
?>
<form>
<div style="display: inline; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;">
<span id="spanButtonPlaceholder"></span>
</div>
</form>
<?php
}
?>
<form action = "process.php" method="post" enctype="multipart/form-data">
<div id="divFileProgressContainer" style="height: 75px;"></div>
<div id="thumbnails"></div>
<input type="submit" name="submit" />
</form>
</div>
</body>
</html>我想达到上传图片的效果,可是点击上传后没有得到$_FILES效果,请问:怎样才能够使表单通过flash上传完图片后再点击提交按钮,然后可能得到$_FILES的值呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货