當前位置:首頁 » 文件管理 » phpflash上傳頭像

phpflash上傳頭像

發布時間: 2023-08-07 16:26:52

php上傳多張圖片代碼

<?php } function news(){?>
<form action="?type=proctNews" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td> </td></tr><tr><td height="30"><label>名稱A:
<input name="title" type="text" id="title" size="30" />
</label></td></tr><tr><td height="30"><label>名稱B:
<input name="title_en" type="text" id="title_en" size="30" />
</label></td></tr><tr><td height="30"><label>分類:
<select name="ptype" id="ptype">
<?php $conn = new db_conn();
$sql = "SELECT * FROM proct_type";
$result = $conn->db_query($sql);
while($rows=mysql_fetch_assoc($result)){?>
<option value="<?php echo $rows['id']; ?>"><?php echo $rows['name']." / ".$rows['name_en']; ?></option>
<?php } $conn->db_close(); ?>
</select>
</label></td></tr><tr><td height="30"><label>圖片:<br>
<input name="file[]" type="file" size="50" /><br>
<input name="file[]" type="file" size="50" /><br>
<input name="file[]" type="file" size="50" /><br>
<input name="file[]" type="file" size="50" /><br>
<input name="file[]" type="file" size="50" /><br>
<input name="file[]" type="file" size="50" /><br>
</label></td></tr><tr><td>說明A:
<input name="text" type="text" id="text" size="30" /></td>
</tr><tr><td>說明B:
<input name="en_text" type="text" id="en_text" size="30" /></td>
</tr><tr><td align="center"><label>
<input type="submit" name="button" id="button" value="提交" />
</label></td></tr><tr><td> </td></tr></table></form>
<?php }function proctNews(){
extract($_POST);
$upimage = "upimage/".date("Ym")."/";//上傳位置
if(!is_dir($upimage)){
mkdir($upimage); }

$filenum=count($_FILES['file']['tmp_name']);
for($i=0;$i<$filenum;$i++){

$file = "";
if(is_uploaded_file($_FILES['file']['tmp_name'][$i])){//是否用POST上傳
if($_FILES['file']['type'][$i] != ("image/jpeg" || "image/pjpeg")){
die(printTop("只能上傳jpg圖像!")); }
$im = imagecreatefromjpeg($_FILES['file']['tmp_name'][$i]);
$file = $upimage.date("YmdHis").rand(1000,9999);
$w = imagesx($im);
$h = imagesy($im);
if($w > 800 || $h > 800){
ResizeImage($im,800,800,$file.".jpg");
}else{ move_uploaded_file($_FILES['file']['tmp_name'][$i],$file.".jpg");}

//以下為增加行
//設置水印類型 1字元串 2圖片 請自行設置
$watertype=1;
//設置水印字元串 請自行設置
$waterstring="MY hand MY mouth";
//設置水印圖片名 請自行設置
$waterimage="water.gif";
$destination=$file.".jpg";
$image_size = getimagesize($destination);

$iinfo=getimagesize($destination,$iinfo);
$nimage=imagecreatetruecolor($image_size[0],$image_size[1]);
$white=imagecolorallocate($nimage,255,255,255);
$black=imagecolorallocate($nimage,0,0,0);
$red=imagecolorallocate($nimage,255,0,0);
imagefill($nimage,0,0,$white);

$simage =imagecreatefromjpeg($destination);
image($nimage,$simage,0,0,0,0,$image_size[0],$image_size[1]);
imagefilledrectangle($nimage,1,$image_size[1]-15,120,$image_size[1],$white);

switch($watertype)
{
case 1: //加水印字元串
imagestring($nimage,2,3,$image_size[1]-15,$waterstring,$black);
break;
case 2: //加水印圖片
$simage1 =imagecreatefromgif("xplore.gif");
image($nimage,$simage1,0,0,0,0,85,15);
imagedestroy($simage1);
break;
}
imagejpeg($nimage, $destination);
imagedestroy($nimage);
imagedestroy($simage);
//以上為增加行//

ResizeImage($im,130,130,$file."n.jpg");}
$date = date("Y-m-d H:i:s");
$conn = new db_conn();
$sql = "INSERT INTO proct (ptype,title,title_en,image,text,text_en,date) VALUES ($ptype,'$title','$title_en','$file','$text','$text_en','$date')";
$result = $conn->db_query($sql);
if($result){
echo printTop("添加成功!");}else{
echo printTop("添加失敗!");}
$conn->db_close();}
}
function types(){?>

⑵ php 圖片上傳預覽功能怎麼實現

<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input type="file" name="fileField" id="fileField" />
<input type="submit" name="submit" id="submit" value="提交" />
</form>
<?php
if($_POST["submit"])
{
$file_gai = $_FILES["fileField"];$filename_gai=$file_gai["tmp_name"];
$destination = basename($file_gai["name"]);
if(!move_uploaded_file ($filename_gai, $destination))
{
echo "<font color='red'>移動文件出錯!</a>";
}else{
echo ("<script>location.href='?file=".urlencode($destination)."'</script>");
}
}if($_GET["file"])
{
echo "<img src='".urldecode($_GET["file"])."'>";
}
?>

⑶ php中上傳文件的方法有多少種

一、傳統的php寫的上傳類。
寫一個php的上傳類,這個方法用到的知識全部是php的,而且技術的難點也不多。
<form method="post" action="upload.php" enctype="multipart/form-data">
<table border=0 cellspacing=0 cellpadding=0 align=center width="100%">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">//隱藏域。這里name必須設置成MAX_FILE_SIZE,其值就是上傳文件的最大長度,單位是B,這里我限製成2M
<input name="file" type="file" value="瀏覽" >
< input type="submit" value="上傳" name="B1">
</table>
</form>

服務端利用php的$_FILES['file']['name']來獲取文件後綴名,具體的代碼自己查找資料看看,這里就不多說了。
總結;這個方法可以用來上傳小於2M的文件或者是圖片,基本的功能可以實現。
二、利用uploadify插件
這個是利用jQuery的上傳插件,上傳可以帶進度條,容易配置。
總結:可以上傳一些大文件,和圖片,而且帶進度條,可以多文件上傳,在WEB中會經常用。
三、利用網路的webupload
WebUploader 是由 Bai FEX 團隊開發的一款以 HTML5 為主,FLASH 為輔的現代文件上傳組件。在現代的瀏覽器裡面能充分發揮 HTML5 的優勢,同時又不摒棄主流IE瀏覽器,沿用原來的 FLASH 運行時,兼容 IE6+,iOS 6+, Android 4+。採用大文件分片並發上傳,極大的提高了文件上傳效率。
四、swfupload的插件

這是一個jquery的上傳插件,功能也非常強大,開發也比較容易,網上有很多的資料,可以自行查找。

⑷ 網頁點擊上傳頭像是如何實現的比如像頭條

代碼如下,此為點擊一個圖片出現選擇文件的html代碼

<!DOCTYPEhtml><html><head>
<metacharset="utf-8">
<title>Demo</title>
<styletype="text/css">
div
{position:relative;
}input
{opacity:0;filter:alpha(opacity=0);height:95px;width:100px;position:absolute;top:0;left:0;z-index:9;
}</style></head><body>
<div>
<inputtype="file">
<imgsrc="http://vip.xcsee.cn/images/qrcode.png">
</div></body></html>
熱點內容
滑板鞋腳本視頻 發布:2025-02-02 09:48:54 瀏覽:432
群暉怎麼玩安卓模擬器 發布:2025-02-02 09:45:23 瀏覽:557
三星安卓12彩蛋怎麼玩 發布:2025-02-02 09:44:39 瀏覽:743
電腦顯示連接伺服器錯誤 發布:2025-02-02 09:24:10 瀏覽:537
瑞芯微開發板編譯 發布:2025-02-02 09:22:54 瀏覽:146
linux虛擬機用gcc編譯時顯示錯誤 發布:2025-02-02 09:14:01 瀏覽:233
java駝峰 發布:2025-02-02 09:13:26 瀏覽:651
魔獸腳本怎麼用 發布:2025-02-02 09:10:28 瀏覽:532
linuxadobe 發布:2025-02-02 09:09:43 瀏覽:212
sql2000資料庫連接 發布:2025-02-02 09:09:43 瀏覽:726