當前位置:編程學習大全網 - 網站源碼 - 網頁中上傳圖片 php代碼問題 高分!!

網頁中上傳圖片 php代碼問題 高分!!

<?php

/*

* Created on 2012-6-7

*

* To change the template for this generated file go to

* Window - Preferences - PHPeclipse - PHP - Code Templates

*/

if( is_uploaded_file($_FILES['upfile']['tmp_name'])){

$upfile=$_FILES["upfile"];

$name=$upfile["name"];

$type=$upfile["type"];

$size=$upfile["size"];

$tmp_name=$upfile["tmp_name"];

$error=$upfile['error'];

switch($type){

case'image/pjpeg':$ok=1;

break;

case'image/jpeg':$ok=1;

break;

case'image/gif':$ok=1;

break;

case'image/png':$ok=1;

break;

}

if($ok&&$error=='0'){

move_uploaded_file($tmp_name,'E:image/'.$name);

echo"上傳成功";}else {echo"上傳失敗";};

}

>

<form action="" method="post" enctype="multipart/form-data" name="upfile">

上傳文件:

<input type="file" name="upfile" >

<input type="submit" value="上傳"/><br/>

</form>

試試這個吧,把這個當成上傳頁面,插入到妳的網頁中應該就行了

  • 上一篇:怎樣用CSS給網站title加小圖標?
  • 下一篇:五糧液盒上的兩串碼什麽意思
  • copyright 2024編程學習大全網