phpappend
代碼如下
form action="upload.php" id="form1" name="form1" enctype="multipart/form-data" method="post" target="uploadIframe"> <!--上傳圖片頁面 --> </form> <iframe name="uploadIframe" id="uploadIframe" style="display:none"></iframe>
然後後台處理完上傳圖片邏輯後返回給前台,利用ajax修改當前頁面DOM對象實現無刷新上傳圖片的友好功能。
實例
代碼如下
a.html <form enctype="multipart/form-data" action="a.php" target="ifram_sign" method="POST"> <input name="submit" id="submit" value="" type="hidden"> <label>上傳文件: <input name="test_file" type="file" id="test_file" size="48"></label> <input type="image" value="立即上傳" id="submit_btn"> </form><iframe name="ifram_sign" src="" frameborder="0" height="0" width="0" marginheight="0" marginwidth="0"></iframe>
php代碼:
代碼如下
<?php
if ($_files["test_file"]["error"] > 0)
{
echo "Error: " . $_files["test_file"]["error"] . "<br />";
}
else
{
//這里的判斷圖片屬性的方法就不寫了。自己擴展一下。
$filetype=strrchr($_files["test_file"]["name"],".");
$filetype=substr($filetype,1,strlen($filetype));
$filename="img/".time("YmdHis").".".$filetype;
move_uploaded_file($_files["test_file"]["tmp_name"],$filename);
echo '<script >alert(1)</script>';
$return="parent.document.getElementByIdx_x('mpic".$pageset_id."').innerhtml='".$dataimgpath."'";
echo "<script >alert('上傳成功')</script>";
echo "<script>{$return}</script>";
}
?>
其實jquery ajax圖片非同步上傳
html:
<!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" lang="en_US" xml:lang="en_US">
<head>
<title>圖片非同步上傳</title>
</head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<link type="text/css" rel="stylesheet" href="css/index.css">
<body>
<div class="frm">
<form name="uploadFrom" id="uploadFrom" action="upload.php" method="post" target="tarframe" enctype="multipart/form-data">
<input type="file" id="upload_file" name="upfile">
</form>
<iframe src="" width="0" height="0" style="display:none;" name="tarframe"></iframe>
</div>
<div id="msg">
</div>
</body>
</html>
index.js
$(function(){
$("#upload_file").change(function(){
$("#uploadFrom").submit();
});
});
function stopSend(str){
var im="<img src='upload/images/"+str+"'>";
$("#msg").append(im);
}
upload.php
<?php
$file=$_files['upfile'];
$name=rand(0,500000).dechex(rand(0,10000)).".jpg";
move_uploaded_file($file['tmp_name'],"upload/images/".$name);
//調用iframe父窗口的js 函數
echo "<script>parent.stopSend('$name')</script>";
?>
非同步上傳圖片幾種方法
『貳』 PHP的頁面查詢結果在本頁顯示,而不是另外一頁顯示
想要在本頁顯示,估計可以採用ajax,你可以先了解下它,然後找一下相關的例子。ajax是一種頁面局部刷新技術,就是你可以使用js來獲取一個頁面的內容,然後動態地顯示在頁面上。
你可以看看jquery封裝好的ajax方法,然後按照實例修改下你的代碼,應該就可以實現你想要的效果了。
將ajax的請求url改寫成另一個頁面的地址,然後將返回的內容使用append等方法拼接到頁面上就可以了。
『叄』 php編程輸出100以內的素數
素數就是只能被 1 和它本身所整除的數。從2~100,逐個判斷素數,如果是素數,就列印,否則不列印。
源代碼如下:
#coding:utf-8
for i in range(2,101):
fg = 0
for j in range(2,i-1):
if i%j == 0:
fg = 1
break
if fg == 0:
print(i)
i = 2
c = []
while i <= 100:
j = 2
while j <= i:
if i % j == 0:
if i == j:
c.append(i)
break
j += 1
i += 1
print(c)
(3)phpappend擴展閱讀
a~b之間的素數的代碼
def su(a,b):
for i in range(a,b):
n = False #默認不是素數,如果是素數,跳出循環
for j in range(2,int(i**0.5)):
if i%j == 0:
n = True
break
if n == False:
print(i,end=" ")
su(100,200)
『肆』 PHP文件寫入的幾種方法
通過fwrite
$file = fopen("test.txt","a+"); //次方法會自動生成文件test,txt,a表示追加寫入,
//w代表替換寫入 fwrite($file,"寫入代碼"); fclose($file);
file_put_content()方法寫入
file_put_contents("test.txt","奧斯卡老\r\n頓積分");//這里說一下\r\n在雙引號下
//才會換行如果單引號就識別不了
//如果想追加寫入內容,這個函數還有第三個參數FILE_APPEND
『伍』 php 數組追加
在PHP裡面,往數組中追加元素最簡單的方法是使用[]賦值,例如需要在$arr添加一條123的語句是$arr[]=123,可以參考下面的代碼:
<?php
$arr=[123,456];
print_r($arr);
$arr[]=789;
print_r($arr);
?>
(5)phpappend擴展閱讀:
PHP函數
constant() 函數返回常量的值。
connection_status() 函數返回當前的連接狀態。
connection_aborted() 函數檢查是否斷開客戶機。
zip_read() 函數讀取打開的 zip 檔案中的下一個文件。
zip_open() 函數打開 ZIP 文件以供讀取。
zip_entry_read() 函數從打開的 zip 檔案項目中獲取內容。
zip_entry_open() 函數打開一個 ZIP 檔案項目以供讀取。
『陸』 php 怎麼在文件尾部寫入內容
可以看看error_log函數和file_put_contents函數(追加模式FILE_APPEND)
『柒』 php怎樣來建立一個表格呀
1、首先創建一個html文件,編寫上基本的代碼,在head頭部中引入jquery路徑,用於調用其中封裝的方法。
『捌』 PHP選中某商品,其屬性連帶過來
用到了jquery,當你輸入一個字以後,使用jquery檢測你的下拉框是否change,如果有,則觸發php函數,根據輸入的內容到資料庫查找出來,已json方式傳過來,然後使用$.each將json讀出,將信息append到下拉菜單後面。
『玖』 php中append是什麼意思
就是追加的意思
『拾』 php如何將一個txt文件的內容追加到另一個txt文件里
打開讀取txt1 用追加的方式寫進txt2就行了啊