国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

<center id="awced"><input id="awced"></input></center>
  • Table of Contents
    1. Reference files
    2. HTML code
    3. JS code
    4. Background processing (PHP)
    5. Foreground call
    Home PHP Framework ThinkPHP How does Thinkphp combine with ajaxFileUpload to implement asynchronous image transmission with ajax?

    How does Thinkphp combine with ajaxFileUpload to implement asynchronous image transmission with ajax?

    May 30, 2023 pm 10:13 PM
    thinkphp ajax ajaxfileupload

    1. Reference files

    First introduce the jQuery and ajaxFileUpload plug-ins. Pay attention to the order. Needless to say, this is true for all plug-ins.

    <script src="__ADMIN__/js/jquery.min.js?v=2.1.4"></script>
    <script src="__ADMIN__/js/ajaxfileupload.js"></script>

    2. HTML code

    <div class="form-group">
        <label class="col-sm-2 control-label">縮略圖</label>
        <div class="col-sm-8">             
            <div id="file-pretty">
                <div>
                    <input type="file" id="file_thumb" name="thumb" class="form-control"  value="">
                    <div class="input-append input-group">
                        <span class="input-group-btn">
                            <button id="btn_thumb" class="btn btn-white" type="button">選擇圖片</button>
                        </span>
                        <input id="info_thumb" name="thumb" class="input-large form-control" type="text" value="{$info.img}">
                    </div>
                </div>
            </div>                     
        </div>
        <div class="col-sm-2"><img id="show_thumb" src="/uploads/image/{$info.thumb}"  alt=""></div>
    </div>

    3. JS code

        <script type="text/javascript">
    	    $(function(){
    	        $("#btn_thumb").click(function(){
    	            $("#file_thumb").click();
    	        });
    
    	        //異步上傳
    	        $("body").delegate(&#39;#file_thumb&#39;, &#39;change&#39;, function(){
    	            var filepath = $("input[name=&#39;thumb&#39;]").val();
    	            var arr = filepath.split(&#39;.&#39;);
    	            var ext = arr[arr.length-1];
    	            //alert(filepath);exit();
    
    	            if(&#39;gif|jpg|png|bmp&#39;.indexOf(ext)>=0){
    	                $.ajaxFileUpload({
    	                  url: &#39;/admin/slide/upload_image&#39;,
    	                  secureurl: false,
    	                  fileElementId: &#39;file_thumb&#39;, //file標簽ID
    	                  dataType: &#39;json&#39;, //返回數(shù)據(jù)類型
    	                  data:{name:&#39;thumb&#39;},
    	                  success:function (data,status){
    	                      $("#info_thumb").val(data);
    	                      $("#show_thumb").attr(&#39;src&#39;,&#39;/uploads/images/&#39;+data);
    	                      $("#info_thumb").focus();
    	                  },
    	                  complete:function (XMLHttpRequest){
    
    	                  },
    	                  error:function (data,status,e){
    	                      layer.alert(&#39;上傳失敗!&#39;);
    	                  },
    	              });
    	            } else {
    	                //清空file
    	                $("#file_thumb").val("");
    	                layer.alert(&#39;請上傳合適的圖片類型!&#39;);
    	            }
    
    	        });
    	    });
        </script>

    4. Background processing (PHP)

        //單文件(包含單文件)異步上傳
        public function upload_image(){
            //圖片上傳
            $file = request()->file(input(&#39;name&#39;));
            $info = $file->move(ROOT_PATH . &#39;public/uploads/images&#39;);
            if($info) {
                return json_encode($info->getSaveName());
            }
        }

    5. Foreground call

    <div id="slideshow">
      <ul class="rslides" id="slider">
        {volist name="data" id="vo"}
        <li><a href="{$vo.url}" rel="external nofollow"  rel="bookmark" target="_blank"> <img src="__UPLOADS__/images/{$vo.img}" max-width="" max-height="" alt="{$vo.title}"></a>
          <p class="slider-caption">{$vo.title}</p>
        </li>
        {/volist}
      </ul>
    </div>

    The above is the detailed content of How does Thinkphp combine with ajaxFileUpload to implement asynchronous image transmission with ajax?. For more information, please follow other related articles on the PHP Chinese website!

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Hot Topics

    PHP Tutorial
    1502
    276
    PHP and Ajax: Building an autocomplete suggestion engine PHP and Ajax: Building an autocomplete suggestion engine Jun 02, 2024 pm 08:39 PM

    Build an autocomplete suggestion engine using PHP and Ajax: Server-side script: handles Ajax requests and returns suggestions (autocomplete.php). Client script: Send Ajax request and display suggestions (autocomplete.js). Practical case: Include script in HTML page and specify search-input element identifier.

    How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

    To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

    There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

    ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

    How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

    Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

    Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

    Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

    How to solve jQuery AJAX request 403 error How to solve jQuery AJAX request 403 error Feb 19, 2024 pm 05:55 PM

    jQuery is a popular JavaScript library used to simplify client-side development. AJAX is a technology that sends asynchronous requests and interacts with the server without reloading the entire web page. However, when using jQuery to make AJAX requests, you sometimes encounter 403 errors. 403 errors are usually server-denied access errors, possibly due to security policy or permission issues. In this article, we will discuss how to resolve jQueryAJAX request encountering 403 error

    How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

    ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

    How to solve the 403 error encountered by jQuery AJAX request How to solve the 403 error encountered by jQuery AJAX request Feb 20, 2024 am 10:07 AM

    Title: Methods and code examples to resolve 403 errors in jQuery AJAX requests. The 403 error refers to a request that the server prohibits access to a resource. This error usually occurs because the request lacks permissions or is rejected by the server. When making jQueryAJAX requests, you sometimes encounter this situation. This article will introduce how to solve this problem and provide code examples. Solution: Check permissions: First ensure that the requested URL address is correct and verify that you have sufficient permissions to access the resource.

    See all articles