php另存圖片
⑴ 網頁圖片如何從php檔強制存成原本的jpg
把圖片網址放到IE瀏覽器上,單獨訪問這個圖片,再點擊右鍵另存為,或者直接用QQ的截圖工具也可以啊
⑵ php 如何使圖片另存為無效
JS的確可以使 右鍵無效。 不過本質上是不可能讓圖片另存無效的。
因為只要你讓別人瀏覽圖片, 那圖片其實就是被對方下載走了。
在FF下 開個FIREBUG 找到你圖片的路徑,直接就可以下載了
⑶ PHP 怎麼把網路圖片存到本地
右擊滑鼠,圖片另存為,ok了
⑷ php,或js如何實現點擊圖片另存為
JS:
使用JS實現單擊連接保存圖片2種形式都可以第一種:
<script>
function SaveAs5(imgURL)
{
var oPop = window.open(imgURL,"","width=1, height=1, top=5000,
left=5000");
for(; oPop.document.readyState != "complete"; )
{ if (oPop.document.readyState == "complete")break; }
oPop.document.execCommand("SaveAs"); oPop.close();
}
</script>
<img src="t_screenshot_17616.jpg" id="DemoImg" border="0"
onclick="SaveAs5(this.src)">
第二種:
<script> function SaveAs5(imgURL)
{
var oPop = window.open(imgURL,"","width=1, height=1, top=5000,
left=5000");
for(; oPop.document.readyState != "complete"; )
{ if (oPop.document.readyState == "complete")break; }
oPop.document.execCommand("SaveAs"); oPop.close();
}
</script>
<img src="../t_screenshot_17616.jpg" id="DemoImg" border="0">
<a href="#" onclick="SaveAs5(document.getElementByIdx_x('DemoImg').src)">
點擊這里下載圖片 </a>
PHP:
<ahref="test.php?url=uploads/1112/1-11122212201R28.jpg">下載</a>
test.php文件代碼:
<?php
$dir=$_GET['url'];//獲取圖片地址$file=fopen($dir,"r");//打開文件
Header("Content-type:application/octet-stream");
Header("Accept-Ranges:bytes");
Header("Accept-Length:".filesize($dir));
Header("Content-Disposition:attachment;filename=".$dir);
echofread($file,filesize($dir));
fclose($file);
exit;
?>
⑸ php 可以多張圖片另存為嗎
你說的是上傳圖片么?上傳圖片的處理是可以多張圖片一起做的。
這樣說吧,幾乎你在瀏覽器能看見的網頁,php都能做
⑹ php如何把圖片存到資料庫,而且讀取出來。
資料庫的欄位類型本來就有image的,直接存取就好了阿。
⑺ PHP存圖片問題
圖片照常保存。然後調用的時候根據調用的需要去生成縮略圖。
或者
提前將需要用到的幾種尺寸的縮略圖保存的時候即生成
最好同比例的縮略圖生成一張比如:需要20*20和200*200的縮略圖完全可以只生成一張200*200的然後調用的位置去限定下圖片的大小就可以。
⑻ php生成的圖片如何保存為jpg
文件名:do.jpg
⑼ PHP如何保存生成的圖片
保存目錄作為變數,,
⑽ PHP怎麼把圖片數據保存為jpg圖片到伺服器目錄
第一步:通過$_FILES獲取文件信息。
第二步:指定新文件名稱以及路徑,並賦值給一個變數。
第三步:通過move_uploaded_file上傳文件。
第四步:上傳成功後,將數值存入資料庫伺服器目錄即可。
代碼如下
1.conn.php
<?
$host="localhost";//資料庫伺服器名稱
$user="root";//用戶名
$pwd="1721";//密碼
$conn=mysql_connect($host,$user,$pwd);
mysql_query("SET
character_set_connection=gb2312,
character_set_results=gb2312,
character_set_client=binary",$conn);
if($conn==FALSE)
{
echo"<center>伺服器連接失敗!<br>請刷新後重試。</center>";
returntrue;
}
$databasename="database";//資料庫名稱
do
{
$con=mysql_select_db($databasename,$conn);
}while(!$con);
if($con==FALSE)
{
echo"<center>打開資料庫失敗!<br>請刷新後重試。</center>";
returntrue;
}
?>
2.upload.php
<?php
if($_GET['action']=="save"){
include_once('conn.php');
include_once('uploadclass.php');
$title=$_POST['title'];
$pic=$uploadfile;
if($title=="")
echo"<Script>window.alert('對不起!你輸入的信息不完整!');history.back()</Script>";
$sql="insertintoupload(title,pic)values('$title','$pic')";
$result=mysql_query($sql,$conn);
//echo"<Script>window.alert('信息添加成功');location.href='upload.php'</Script>";
}
?>
<html>
<head>
<title>文件上傳實例</title>
</head>
<body>
<formmethod="post"action="?action=save"enctype="multipart/form-data">
<tableborder=0cellspacing=0cellpadding=0align=centerwidth="100%">
<tr>
<tdwidth=55height=20align="center"></TD>
<tdheight="16">
<tablewidth="48%"height="93"border="0"cellpadding="0"cellspacing="0">
<tr>
<td>標題:</td>
<td><inputname="title"type="text"id="title"></td>
</tr>
<tr>
<td>文件:</td>
<td><label>
<inputname="file"type="file"value="瀏覽">
<inputtype="hidden"name="MAX_FILE_SIZE"value="2000000">
</label></td>
</tr>
<tr>
<td></td>
<td><inputtype="submit"value="上傳"name="upload"></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
3.uploadclass.php
<?php
$uploaddir="upfiles/";//設置文件保存目錄注意包含/
$type=array("jpg","gif","bmp","jpeg","png");//設置允許上傳文件的類型
$patch="upload/";//程序所在路徑
//獲取文件後綴名函數
functionfileext($filename)
{
returnsubstr(strrchr($filename,'.'),1);
}
//生成隨機文件名函數
functionrandom($length)
{
$hash='CR-';
$chars='';
$max=strlen($chars)-1;
mt_srand((double)microtime()*1000000);
for($i=0;$i<$length;$i++)
{
$hash.=$chars[mt_rand(0,$max)];
}
return$hash;
}
$a=strtolower(fileext($_FILES['file']['name']));
//判斷文件類型
if(!in_array(strtolower(fileext($_FILES['file']['name'])),$type))
{
$text=implode(",",$type);
echo"您只能上傳以下類型文件:",$text,"<br>";
}
//生成目標文件的文件名
else{
$filename=explode(".",$_FILES['file']['name']);
do
{
$filename[0]=random(10);//設置隨機數長度
$name=implode(".",$filename);
//$name1=$name.".Mcncc";
$uploadfile=$uploaddir.$name;
}
while(file_exists($uploadfile));
if(move_uploaded_file($_FILES['file']['tmp_name'],$uploadfile))
{
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
echo"上傳失敗!";
}
else
{//輸出圖片預覽
echo"<center>您的文件已經上傳完畢上傳圖片預覽:</center><br><center><imgsrc='$uploadfile'></center>";
echo"<br><center><ahref='upload.htm'>繼續上傳</a></center>";
}
}
}
?>