請給我提醒:我想整合圖片上傳到我的註冊過程。你知道一些插件或腳本爲此目的(上傳,調整大小,把鏈接到db_table)?圖片上傳整合到註冊頁面
回答
查找下面的代碼使用GD庫上傳和裁剪圖像。
<?php
function createThumb($upfile, $dstfile, $max_width, $max_height){
$size = getimagesize($upfile);
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width/$width;
$y_ratio = $max_height/$height;
if(($width <= $max_width) && ($height <= $max_height)) {
$tn_width = $width;
$tn_height = $height;
} elseif (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
} else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
if($size['mime'] == "image/jpeg"){
$src = ImageCreateFromJpeg($upfile);
$dst = ImageCreateTrueColor($tn_width, $tn_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
imageinterlace($dst, true);
ImageJpeg($dst, $dstfile, 100);
} else if ($size['mime'] == "image/png"){
$src = ImageCreateFrompng($upfile);
$dst = ImageCreateTrueColor($tn_width, $tn_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
Imagepng($dst, $dstfile);
} else {
$src = ImageCreateFromGif($upfile);
$dst = ImageCreateTrueColor($tn_width, $tn_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
imagegif($dst, $dstfile);
}
}
//usage
if(isset($_FILES['upload_Image']['name']) && $_FILES['upload_Image']['name']!=='') {
$ext = substr($_FILES['upload_Image']['name'], strpos($_FILES['upload_Image']['name'],'.'), strlen($_FILES['upload_Image']['name'])-1);
$imgNormal = time().$ext;
$normalDestination = "Photos/Orignal/" . $imgNormal;
$httpRootLarge = "Photos/Large/" . $imgNormal;
$httpRootSmall = "Photos/Small/" . $imgNormal;
$httpRootThumb = "Photos/Thumb/" . $imgNormal;
move_uploaded_file($_FILES['upload_Image']['tmp_name'], $normalDestination);
createThumb($normalDestination,$httpRootLarge,680,604); #For 604x604 Image
createThumb($normalDestination,$httpRootSmall,500,300); #For 500x300 Image
createThumb($normalDestination,$httpRootThumb,130,100); #For 130x100 Image
}
?>
<form action="" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="upload_Image" id="upload_Image" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
在你的mysql表中保存$ imgNormal值。
http://pastebin.com/Ed2YHV6w – mplungjan
你可以在mysql上載圖像,並使用imagemagic或gd庫調整它的大小。
進入mysql表嗎?沒有。我想將它們上傳到文件夾,然後獲取圖像鏈接,並將該鏈接放入dn-table –
你有用於此目的的PHP腳本嗎? –
如果你想上傳到一個文件夾。您必須使用enctype =「multipart/form-data」爲文件夾設置正確的權限並使用表單上傳,並使用$ _FILE獲取訪問權限。 – NiLL
您可以使用move_uploaded_file to upload,但請注意,你的表單元素也必須有屬性enctype="multipart/form-data"
圖像縮放,你可以從GD庫使用的功能。快速搜索「php縮放圖像」可以揭示這個主題的許多有用鏈接。
更不用說manual itself有許多有用的示例腳本,包括你之後的一個腳本。
看來你對PHP很陌生。我建議你瞭解PHP manual。將其用作您的第一個PHP資源,然後將其作爲互聯網上的文章。在用完所有其他選項後,請到這裏。看起來你甚至沒有嘗試解決這個問題或自己研究它。
你可以看看像http://github.com/valums/file-uploader和phpthumb這樣的文件上傳器的大小,雖然其他海報提到,如果你想了解更多關於它的信息並不複雜。
- 1. 上傳到註冊頁面後編輯/刪除圖片
- 2. Facebook圖表API:上傳照片到頁面相冊
- 3. Django - 註冊表不能上傳圖片
- 4. 將圖片上傳到臉書頁面
- 5. PHP註冊到WWW頁面
- 6. 註冊頁面
- 7. Facebook圖表API:上傳頁面圖片
- 8. 將照片上傳到粉絲頁面相冊
- 9. 圖片庫整合到網頁
- 10. 燈箱CSS/JS圖庫整合到WordPress圖片上傳
- 11. 聯合登錄和註冊頁面?
- 12. 將圖片上傳到臉譜網頁的相冊
- 13. 如何獲取相冊ID並將圖片上傳到粉絲頁面專輯
- 14. 在註冊頁面
- 15. woocommerce註冊頁面
- 16. jsp註冊頁面
- 17. grails註冊頁面
- 18. 從當前HTML頁面上傳圖片
- 19. 無頁面刷新上傳圖片
- 20. 圖片上傳無頁面刷新
- 21. Ajax圖片上傳刷新頁面?
- 22. ASP.NET上傳圖片後刷新頁面
- 23. 在codeigniter的頁面圖片上傳
- 24. 註冊頁面沒有註冊用戶
- 25. Facebook上傳照片到頁面
- 26. 上傳照片到Facebook粉絲頁面
- 27. 調整上傳圖片yii
- 28. 登陸頁面上的Rails註冊完成註冊
- 29. django註冊登錄並在一個頁面上註冊
- 30. cakephp:註冊頁面上的註冊鏈接不工作
在問這個問題之前你做過什麼研究? –
我沒有找到任何上傳和調整大小的東西。如果你知道一些腳本請給我一個鏈接 –