php 多檔案上傳組件_PHP教程

來源:互聯網
上載者:User




php教程 多檔案上傳組件






縮圖模式


這個選擇框的資料將以post形式和圖片一起傳送到伺服器
老虎 兔子 駿馬
石頭 剪子 布




改變視窗:高



寬:


 


















php處理檔案

// 注意:使用組件上傳,不可以使用 $_files["filedata"]["type"] 來判斷檔案類型
mb_http_input("utf-8");
mb_http_output("utf-8");

//---------------------------------------------------------------------------------------------
//組件設定a.md5file為2,3時 的執行個體代碼

if(getget('access2008_cmd')=='2'){ // 提交md5驗證後的檔案資訊進行驗證
//getget("access2008_file_name") '檔案名稱
//getget("access2008_file_size") '檔案大小,單位位元組
//getget("access2008_file_type") '檔案類型 例如.gif .png
//getget("access2008_file_md5") '檔案的md5簽名

die('0'); //返回命令 0 = 開始上傳檔案, 2 = 不上傳檔案,前台直接顯示上傳完成
}
if(getget('access2008_cmd')=='3'){ //提交檔案資訊進行驗證
//getget("access2008_file_name") '檔案名稱
//getget("access2008_file_size") '檔案大小,單位位元組
//getget("access2008_file_type") '檔案類型 例如.gif .png

die('1'); //返回命令 0 = 開始上傳檔案,1 = 提交md5驗證後的檔案資訊進行驗證, 2 = 不上傳檔案,前台直接顯示上傳完成
}
//---------------------------------------------------------------------------------------------

$type=filekzm($_files["filedata"]["name"]);
if ((($type == ".gif")
|| ($type == ".png")
|| ($type == ".jpeg")
|| ($type == ".jpg")
|| ($type == ".bmp"))
&& ($_files["filedata"]["size"] < 200000))
{
if ($_files["filedata"]["error"] > 0)
{
echo "返回錯誤: " . $_files["filedata"]["error"] . "
";
}
else
{
echo "上傳的檔案: " . $_files["filedata"]["name"] . "
";
echo "檔案類型: " . $type . "
";
echo "檔案大小: " . ($_files["filedata"]["size"] / 1024) . " kb
";
echo "臨時檔案: " . $_files["filedata"]["tmp_name"] . "
";

if (file_exists( $_files["filedata"]["name"]))
{
echo $_files["filedata"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_files["filedata"]["tmp_name"],
'./'.$_files["filedata"]["name"]);
echo "stored in: " . $_files["filedata"]["name"]."
";
echo "md5效驗:".getget("access2008_file_md5")."
";
echo "
上傳成功!你選擇的是".getpost("select")."--".getpost("select2")."";
}
}
}
else
{
echo "上傳失敗,請檢查檔案類型和檔案大小是否符合標準
檔案類型:".$type.'
檔案大小:'.($_files["filedata"]["size"] / 1024) . " kb";
}

function filekzm($a)
{
$c=strrchr($a,'.');
if($c)
{
return $c;
}else{
return '';
}
}

function getget($v)// 擷取get
{
if(isset($_get[$v]))
{
return $_get[$v];
}else{
return '';
}
}

function getpost($v)// 擷取post
{
if(isset($_post[$v]))
{
return $_post[$v];
}else{
return '';
}
}
?>

源碼包下載
http://down.php100.com/php/2011/0311/22880.html


http://www.bkjia.com/PHPjc/444791.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444791.htmlTechArticlehtml xmlns=http://www.w3.org/1999/xhtml xml:lang=zh_cn lang=zh_cn head meta http-equiv=content-type content=text/html; charset=utf-8 / titlephp教程 多檔案上傳組件/title /h...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.