還有什麼比代碼更清晰的講解
php
html代碼:html
method="post" enctype="multipart/form-data"
<html> <head> <title>SAE上傳文件到storage 實例演示</title> </head> <body> <form action="test.php" method="post" enctype="multipart/form-data"> <input type="file" name="file" /> <input type="submit" value="submit"> </form> </body> </html>
<?php if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else{ $filename = explode(".",$_FILES["file"]["name"]); $uplodetime = date("ymdHis"); $filename[0]=$uplodetime; $giftpicname=implode(".",$filename); $tmp_name = $_FILES['file']['tmp_name']; $q= new SaeStorage(); $result=$q->upload("giftinf",$giftpicname, $tmp_name); $giftpicurl=$q->getUrl("giftinf",$giftpicname); if(!$result) { echo "error"; } echo $giftpicurl; } ?> <img src="<?=$giftpicurl?>"/>