加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swfupload --forms改版

发布时间:2020-12-15 06:54:53 所属栏目:百科 来源:网络整理
导读://index.php!DOCTYPE htmlhtmlheadtitleSWFUpload Demos - Classic Form Demo/titlelink href="../css/default.css" rel="stylesheet" type="text/css" /script type="text/javascript" src="../swfupload/swfupload.js"/scriptscript type="text/javascript
//index.php


<!DOCTYPE html>
<html>
<head>
<title>SWFUpload Demos - Classic Form 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/fileprogress.js"></script>
<script type="text/javascript" src="js/handlers.js"></script>
<script type="text/javascript">
		var swfu;

		window.onload = function () {
			swfu = new SWFUpload({
				// Backend settings
				upload_url: "upload.php",file_post_name: "resume_file",// Flash file settings
				file_size_limit : "10 MB",file_types : "*.*",// or you could use something like: "*.doc;*.wpd;*.pdf",file_types_description : "All Files",file_upload_limit : 0,file_queue_limit : 1,// Event handler settings
				swfupload_loaded_handler : swfUploadLoaded,file_dialog_start_handler: fileDialogStart,file_queued_handler : fileQueued,file_queue_error_handler : fileQueueError,file_dialog_complete_handler : fileDialogComplete,//upload_start_handler : uploadStart,// I could do some client/JavaScript validation here,but I don't need to.
				swfupload_preload_handler : preLoad,swfupload_load_failed_handler : loadFailed,upload_progress_handler : uploadProgress,upload_error_handler : uploadError,upload_success_handler : uploadSuccess,upload_complete_handler : uploadComplete,// Button Settings
				button_image_url : "XPButtonUploadText_61x22.png",button_placeholder_id : "spanButtonPlaceholder",button_width: 61,button_height: 22,// Flash Settings
				flash_url : "../swfupload/swfupload.swf",flash9_url : "../swfupload/swfupload_fp9.swf",custom_settings : {
					progress_target : "fsUploadProgress",upload_successful : false
				},// Debug settings
				debug: false
			});

		};
	</script>
</head>
<body>
<div id="header">
	<h1 id="logo"><a href="../">SWFUpload</a></h1>
	<div id="version">v2.5.0</div>
</div>

<div id="content">

	<h2>Classic Form Demo</h2>
	<form id="form1" action="thanks.php" enctype="multipart/form-data" method="post">
		<p>This demo shows how SWFUpload might be combined with an HTML form.  It also demonstrates graceful degradation (using the graceful degradation plugin).
			This demo also demonstrates the use of the server_data parameter.  This demo requires Flash Player 9+</p>
		<div class="fieldset">
			<span class="legend">Submit your Application</span>
			<table style="vertical-align:top;">
				<tr>
					<td><label for="lastname">Last Name:</label></td>
					<td><input name="lastname" id="lastname" type="text" style="width: 200px" /></td>
				</tr>
				<tr>
					<td><label for="firstname">First Name:</label></td>
					<td><input name="firstname" id="firstname" type="text" style="width: 200px" /></td>
				</tr>
				<tr>
					<td><label for="education">Education:</label></td>
					<td><textarea name="education"  id="education" cols="0" rows="0" style="width: 400px; height: 100px;"></textarea></td>
				</tr>
				<tr>
					<td><label for="txtFileName">Resume:</label></td>
					<td>
						<div>
							<div>
								<input type="text" id="txtFileName" disabled="true" style="border: solid 1px; background-color: #FFFFFF;" />
								<span id="spanButtonPlaceholder"></span>
								(10 MB max)
							</div>
							<div class="flash" id="fsUploadProgress">
								<!-- This is where the file progress gets shown.  SWFUpload doesn't update the UI directly.
											The Handlers (in handlers.js) process the upload events and make the UI updates -->
							</div>
							<input type="hidden" name="hidFileID" id="hidFileID" value="" />
							<!-- This is where the file ID is stored after SWFUpload uploads the file and gets the ID back from upload.php -->
						</div>
					</td>
				</tr>
				<tr>
					<td><label for="references">References:</label></td>
					<td><textarea name="references" id="references" cols="0" rows="0" style="width: 400px; height: 100px;"></textarea></td>
				</tr>

				<tr>
					<td><label for="images">images:</label></td>
					<td><input type="file" name="images" id="images" /></td>
				</tr>

			</table>
			<br />
			<input type="submit" value="Submit Application" id="btnSubmit" />
		</div>
	</form>
</div>
</body>
</html>
//upload.php

<?php
	// The Demos don't save files

	if (isset($_FILES["resume_file"]) && is_uploaded_file($_FILES["resume_file"]["tmp_name"]) && $_FILES["resume_file"]["error"] == 0) {
		echo $_FILES["resume_file"]["name"];	// Create a pretend file id,this might have come from a database.
	}

	if (isset($_FILES["images"]) && is_uploaded_file($_FILES["images"]["tmp_name"]) && $_FILES["images"]["error"] == 0) {
		echo $_FILES["images"]["name"];	// Create a pretend file id,this might have come from a database.
	}

	$file_name = $_FILES["resume_file"]["name"];

	$file_name = mktime() . $file_name;

	if (!@move_uploaded_file($_FILES["resume_file"]["tmp_name"],$file_name)) {
		echo "文件无法保存.";
		exit(0);
	}else{
		echo "文件已经保存。";
	}

	exit(0);	// If there was an error we don't return anything and the webpage will have to deal with it.
?>

//thanks.php


<?php

// Check for a degraded file upload,this means SWFUpload did not load and the user used the standard HTML upload
$used_degraded = false;
$resume_id = "";
if (isset($_FILES["resume_degraded"]) && is_uploaded_file($_FILES["resume_degraded"]["tmp_name"]) && $_FILES["resume_degraded"]["error"] == 0) {
    $resume_id = $_FILES["resume_degraded"]["name"];

    $used_degraded = true;
}

if (isset($_FILES["images"]) && is_uploaded_file($_FILES["images"]["tmp_name"]) && $_FILES["images"]["error"] == 0) {
    $images_id = $_FILES["images"]["name"];

    $file = $_FILES["images"]["name"];
	//$file = mktime() . $file;
	echo $_FILES["images"]["name"];
	if(!@move_uploaded_file($_FILES["images"]["tmp_name"],$file))
	{
		echo "image no";
	}
	else {
		echo "image yes";
	}

    $used_degraded = true;
}

if (isset($_FILES["images"]) && is_uploaded_file($_FILES["images"]["tmp_name"]) && $_FILES["images"]["error"] == 0) {
    $images_size = $_FILES["images"]["size"];

    $used_degraded = true;
}

// Check for the file id we should have gotten from SWFUpload
if (isset($_POST["hidFileID"]) && $_POST["hidFileID"] != "" ) {
	$resume_id = $_POST["hidFileID"];
}

?>


<?php

	/*mysql_connect("localhost","root","zq19890319");
	mysql_select_db("swfupload");

	$file_name = $_FILES["resume_degraded"]['name'];

	$file_name = mktime() . $file_name;

	if (!@move_uploaded_file($_FILES["resume_degraded"]["tmp_name"],$save_path.$file_name)) {
		HandleError("文件无法保存.");
		exit(0);
	}else{
		mysql_query("insert into swfupload (id,video,num) values (NULL,'$file_name',$num)");
	}
	echo "File Received";
	exit(0);


function HandleError($message) {
	header("HTTP/1.1 500 Internal Server Error");
	echo $message;
}*/

?>



<!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 - Classic Form Demo</title>
<link href="../css/default.css" rel="stylesheet" type="text/css" />
</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>Classic Form Demo</h2>
	<?php if ($resume_id == "") { ?>
		<p>Your resume was not received.</p>
	<?php } else { ?>
		<table>
			<tr>
				<td>Last Name: </td>
				<td><?php echo htmlspecialchars($_POST["lastname"]); ?> </td>
			</tr>
			<tr>
				<td>First Name: </td>
				<td><?php echo htmlspecialchars($_POST["firstname"]); ?> </td>
			</tr>
			<tr>
				<td>Education Name: </td>
				<td><?php echo htmlspecialchars($_POST["education"]); ?> </td>
			</tr>
			<tr>
				<td>Resume ID: </td>
				<td><?php echo htmlspecialchars($resume_id); ?> </td>
			</tr>
			<tr>
				<td>References: </td>
				<td><?php echo htmlspecialchars($_POST["references"]); ?> </td>
			</tr>

			<tr>
				<td>Images: </td>
				<td><?php echo htmlspecialchars($images_id); ?> </td>
			</tr>

			<tr>
				<td>Images: </td>
				<td><?php echo htmlspecialchars($images_size); ?> </td>
			</tr>

		</table>
		<?php
		if ($used_degraded) { ?>
		<p>You used the standard HTML form.</p>
		<?php } ?>
		<hr width="90%" />
		<p> Thank you for your submission. </p>
	<?php } ?>
	<p><a href="index.php">Submit another Application</a></p>
	<p> Thanks for trying this demo.  Your files are discarded for the purposes of this demo. </p>
</div>
</body>
</html>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读