php+jquery实现图片上传预览_和拖动位置值,PHP教程:thinkphp jquery实现图片上传和预览效果...
《PHP教程:thinkphp jquery實(shí)現(xiàn)圖片上傳和預(yù)覽效果》要點(diǎn):
本文介紹了PHP教程:thinkphp jquery實(shí)現(xiàn)圖片上傳和預(yù)覽效果,希望對您有用。如果有疑問,可以聯(lián)系我們。
PHP學(xué)習(xí)
PHP學(xué)習(xí)那個(gè)file按鈕樣式先忽略
PHP學(xué)習(xí)點(diǎn)擊選擇圖片(瀏覽),隨便選一張圖片
PHP學(xué)習(xí)
PHP學(xué)習(xí)js代碼如下
PHP學(xué)習(xí)
//上傳圖片立即預(yù)覽
function PreviewImage(imgFile) {
var filextension = imgFile.value.substring(imgFile.value
.lastIndexOf("."), imgFile.value.length);
filextension = filextension.toLowerCase();
if ((filextension != '.jpg') && (filextension != '.gif')
&& (filextension != '.jpeg') && (filextension != '.png')
&& (filextension != '.bmp')) {
alert("對不起,系統(tǒng)僅支持標(biāo)準(zhǔn)格式的照片,請您調(diào)整格式后重新上傳,謝謝 !");
imgFile.focus();
} else {
var path;
if (document.all)//IE
{
imgFile.select();
path = document.selection.createRange().text;
document.getElementById("photo_info").innerHTML = "";
document.getElementById("photo_info").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='scale',src=\""
+ path + "\")";//使用濾鏡效果
} else//FF
{
path = window.URL.createObjectURL(imgFile.files[0]);// FF 7.0以上
//path = imgFile.files[0].getAsDataURL();// FF 3.0
document.getElementById("photo_info").innerHTML = "";
//document.getElementById("img1").src = path;
}
}
}
PHP學(xué)習(xí)html代碼,其實(shí)不重要啦
PHP學(xué)習(xí)
物品圖片
選擇圖片
class="glyphicon glyphicon-picture" aria-hidden="true">
οnchange='PreviewImage(this)' />
style="color: red;">*
?詳細(xì)描述name="info_desc" placeholder="如需補(bǔ)充,請?zhí)顚?.." title="可包含中文數(shù)字和常用字符">
PHP學(xué)習(xí)css代碼就不上了啊
順便補(bǔ)充一下thinkphp上傳圖片代碼,把整個(gè)發(fā)布消息都拷過了算了
PHP學(xué)習(xí)
public function loseThing(){
$m=M('info');
$m->create();
$upload = new \Think\Upload();// 實(shí)例化上傳類
$upload->maxSize = 3145728 ;// 設(shè)置附件上傳大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg','bmp');// 設(shè)置附件上傳類型
$upload->rootPath = './Public/';
$upload->savePath = '/Uploads/'; // 設(shè)置附件上傳目錄
$upload->autoSub = false;
// 上傳文件
$info = $upload->upload();
if($info) {
// 上傳成功
foreach($info as $file){
$m->info_photo=$file['savename'];
}
}
$m->create_time=date('Y-m-d H:i:s',time());
$m->uid=$_SESSION['id'];
$m->username=$_SESSION['username'];
/* $m->user_img=$_SESSION['filename']; */
$m->info_type="尋物啟事";//信息類型為失物
$lastId=$m->add();
if($lastId){
$this->success('發(fā)布成功');
}else{
$this->error('發(fā)布失敗,請先登錄');
}
}
PHP學(xué)習(xí)以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持維易PHP.
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的php+jquery实现图片上传预览_和拖动位置值,PHP教程:thinkphp jquery实现图片上传和预览效果...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 计算机综合应用实验,计算机综合应用实验二
- 下一篇: java 正则首位8或者9的8位数字_从