茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    使用jquery.form.js實現(xiàn)圖片上傳的方法
    來源:易賢網(wǎng) 閱讀:1741 次 日期:2016-07-06 09:42:18
    溫馨提示:易賢網(wǎng)小編為您整理了“使用jquery.form.js實現(xiàn)圖片上傳的方法”,方便廣大網(wǎng)友查閱!

    這篇文章主要介紹了使用jquery.form.js實現(xiàn)圖片上傳的方法,涉及jquery使用表單插件jquery.form.js進(jìn)行圖片上傳的提交、類型驗證、執(zhí)行結(jié)果回調(diào)顯示等技巧,非常簡單實用,需要的朋友可以參考下

    本文實例講述了使用jquery.form.js實現(xiàn)圖片上傳的方法。分享給大家供大家參考,具體如下:

    testupfile2.php

    <?php

    header('Content-type:text/html;charset=utf-8');

    include_once 'includes/common.inc.php';

     if(!empty($_FILES['upfile'])){

     //文件格式

     $image=array('image/jpg',

       'image/jpeg',

       'image/png',

       'image/pjpeg',

       'image/gif',

       'image/bmp',

       'image/x-png'

     );

    $updir=$_SERVER['DOCUMENT_ROOT'].$_config['g']['baseUrl'].'/attached/images/';

    $upfile=$_FILES['upfile'];

    $name=$upfile['name'];

    $ext=substr($upfile['name'],strpos($upfile['name'],'.'));

    $upname=md5(time().rand(1, 1000)).$ext;

    $type=$upfile['type'];

    $size=$upfile['size'];

    $tmp_name=$upfile['tmp_name'];

    $error=$upfile['error'];

    $ok=0;

     foreach ($image as $key=>$value) {

     if($type==$value)$ok=1;

     }

     if($ok=='1' && $error=='0'){

     move_uploaded_file($tmp_name,$updir.$upname);

     //echo '<br>'.$tmp_name.'<br>'.$upname.'<br>'.$updir.'<br>'.$ext.'上傳成功';

     //echo '上傳成功';

     echo $upname;

     //$im=$updir.$upname;

     //echo $im;

     //echo '<img src='.$updir.$upname.' />';

     //$views->assign('image',$upname);

     //$views->display('default/testupfile.html');

     }

     else echo '上傳失敗2';

    }

    else echo '上傳失敗1';

    ?>

    testupfile.html

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

    "http://www.w3.org/TR/html4/loose.dtd">

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>Insert title here</title>

    <script type="text/javascript" src="<!--{$baseUrl}-->/scripts/jquery.js"></script>

    <script type="text/javascript" src="<!--{$baseUrl}-->/scripts/jquery.form.js"></script>

    <script type="text/javascript">

    $(function(){

     //jquery.form image1

     $("#upimage").bind("click",function(){

     if($("#upfile").val()==""){

      alert("請選擇一個圖片文件,再點擊");

      return;

     }

     $("#form1").ajaxSubmit({

      url:"testupfile2.php",

      type:"POST",

      //date:"upfile=upfile",

      success:function(response){

      alert(response);

      $("#ln").empty();

      $("#ln").append("<img src='<!--{$baseUrl}-->/attached/images/"+response+"' width='100' height='60'/>");

      $("#im1").val(response);

      },

      error:function(msg){

      alert("出錯了");

      }

     });

     });

     //jquery.form image2

     $("#upimage2").bind("click",function(){

     if($("#upfile2").val()==""){

      alert("請選擇一個圖片文件,再點擊2");

      return;

     }

     $("#form2").ajaxSubmit({

      url:"testupfile2.php",

      type:"POST",

      //date:"upfile=upfile2",

      success:function(response2){

      alert(response2);

      $("#ln2").empty();

      $("#ln2").append("<img src='<!--{$baseUrl}-->/attached/images/"+response2+"' width='100' height='60'/>");

      $("#im2").val(response2);

      },

      error:function(msg){

      alert("出錯了");

      }

     });

     });

    });

    </script>

    </head>

    <body>

    文件上傳

    <form enctype="multipart/form-data" id="form1" method="post" action="">

    文件:

     <input type="file" name="upfile" id="upfile"><input type="button" id="upimage" value="圖片上傳1">

     <input type="text" name="im1" id="im1" value="" />

    </form>

    <form enctype="multipart/form-data" id="form2" method="post" action="">

    文件:

     <input type="file" name="upfile" id="upfile2"><input type="button" id="upimage2" value="圖片上傳2">

     <input type="text" name="im2" id="im2" value="" />

    </form>

    <div id="ln">tu</div><br>

    <div id="ln2">tu2</div>

    </body>

    </html>

    希望本文所述對大家jQuery程序設(shè)計有所幫助。

    更多信息請查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機(jī)網(wǎng)站地址:使用jquery.form.js實現(xiàn)圖片上傳的方法
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026上岸·考公考編培訓(xùn)報班

    • 報班類型
    • 姓名
    • 手機(jī)號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報警專用圖標(biāo)