国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > PHP > 正文

PHP SWFUpload多文件上傳處理

2020-03-22 19:09:27
字體:
來源:轉載
供稿:網友
  • 由于工作需求,開始study我不是很熟悉的文件上傳部份,而且又要大量文件可以批次上傳!!

    可以不要一開始就讓我頭有點痛嗎...

    發現了有幾套,大約看過之后,我還是比較喜歡與FLASH整合的SWFUpload,操作感覺也很簡約順暢

    我就是愛有時尚感的東東XD

    不過,很多文章都交代得不是很清楚,連官方文件都是含含糊糊

    官方Demo頁 http://demo.swfupload.org/v220/index.htm

    于是就著手更改他的范例,來弄成我要的東西

    index.php

    <?phpsession_start(); if (count($_FILES)) {        // Handle degraded form uploads here.  Degraded form uploads are POSTed to index.php.  SWFUpload uploads// are POSTed to upload.php} ?><!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><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>SWFUpload測試</title><link href="css/default.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="js/swfupload/swfupload.js"></script><script type="text/javascript" src="js/swfupload.queue.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 upload1; window.onload = function() {upload1 = new SWFUpload({// Backend Settingsupload_url: "upload.php",  <-- 處理上傳動作post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"}, // File Upload Settingsfile_size_limit : "10240",  <--文件上傳大小限制 // 10MBfile_types : "*.*",  <-- 上傳文件類型file_types_description : "All Files",file_upload_limit : "50",  <--  一次上傳數量限制file_queue_limit : "0", // Event Handler Settings (all my handlers are in the Handler.js file)file_dialog_start_handler : fileDialogStart,file_queued_handler : fileQueued,file_queue_error_handler : fileQueueError,file_dialog_complete_handler : fileDialogComplete,upload_start_handler : uploadStart,upload_progress_handler : uploadProgress,upload_error_handler : uploadError,upload_success_handler : uploadSuccess,upload_complete_handler : uploadComplete, // Button Settingsbutton_image_url : "js/XPButtonUploadText_61x22.png",  <-- 按鈕圖片路徑button_text:    ,    <--   也可以用文字表示,可以用CSS增加樣式button_placeholder_id : "spanButtonPlaceholder1",   <--  取代成按鈕的元素IDbutton_width: 61,    <---  寬button_height: 22,  <---  高 // Flash Settingsflash_url : "js/swfupload/swfupload.swf",  custom_settings : {progressTarget : "fsUploadProgress1",cancelButtonId : "btnCancel1"}, // Debug Settingsdebug: false  <--  Debug模式開啟與關閉});     }</script></head> <body><div id="content"><h2>多檔上傳</h2><form id="form1" action="index.php" method="post" enctype="multipart/form-data"><p></p><table><tr valign="top"><td><div><div style="padding-left: 5px;"><span id="spanButtonPlaceholder1"></span><input id="btnCancel1" type="button" value="Cancel Uploads" onclick="cancelQueue(upload1);" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" /><br /></div><div class="fieldset flash" id="fsUploadProgress1"> <span class="legend">文件上傳進度</span></div></div></td> </tr> </table>  </form></div></body></html>

    upload.php

    <?php //設置sessionif (isset($_POST["PHPSESSID"])) { session_id($_POST["PHPSESSID"]); } session_start();   //做個簡易的錯誤判斷,顯示于Debug中 if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) { echo "上傳時出現錯誤 - 無法取得文件名。"; }  //FILES參數 $img = $_FILES["Filedata"]["tmp_name"]; $imgname = substr(md5(time().$_FILES["Filedata"]["name"]),0,16).$_FILES["Filedata"]["name"]; $path = './images/'.$imgname; //www.it165.net if(@move_uploaded_file($img, $path)) echo '<a href="http://'.$_SERVER['HTTP_HOST'].'/weine/images/'.$imgname.'" target="_blank">'.$_FILES['Filedata']['name'].'</a><BR>上傳成功!'; else echo '圖片上傳發生錯誤。'; ?>        

    鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

  • 發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 清远市| 广饶县| 酉阳| 长武县| 中阳县| 宁夏| 井研县| 绥宁县| 周口市| 伊吾县| 宣武区| 民县| 黑山县| 上犹县| 年辖:市辖区| 沐川县| 庆云县| 无为县| 五河县| 托克逊县| 道孚县| 大田县| 民乐县| 新余市| 阿坝县| 通渭县| 临江市| 治县。| 阿图什市| 南平市| 弋阳县| 四平市| 芜湖县| 宜州市| 涡阳县| 曲靖市| 山阴县| 五莲县| 罗田县| 舞阳县| 洱源县|