首頁 web前端 js教程 Ajax配合Spring實作檔案上傳功能碼

Ajax配合Spring實作檔案上傳功能碼

Jan 01, 2018 pm 07:38 PM
ajax spring 文件

最近在開發一個可以上傳圖片到伺服器的web表面頁面,下面給大家分享需求和實現思路還有ajax源碼,對ajax感興趣的的朋友參考下Ajax配合Spring實現文件上傳功能哦!

由於專案需要,開發一個可以上傳圖片到伺服器的網頁表單頁面。

一、 需求

Web表單頁面,可以透過表單上傳圖片以及其他文字資訊。

二、 圖片上傳的流程

之前沒有做過這類頁面,透過查詢資料。發現比較常見的做法,是先將圖片上傳到伺服器端的某個文件目錄下,伺服器向前台返回圖片的存儲路徑;之後,前台將圖片存儲路徑以及其他表單信息一起提交到服務器,所有的表單信息存儲在資料庫中。

三、 方法

由於專案需要,我在這裡介紹兩種圖片上傳方法,第一種是使用ajax對一個圖片直接上傳;第二種是先在前台將圖片切割為較小的文件,之後使用ajax分別上傳圖片到伺服器,伺服器實現對文件的拼接。 (方法二適合較大文件的上傳)下面我分別對兩種方法做介紹。

方法一:直接上傳

#1 html頁面


<pre name="code" class="html"><!DOCTYPE html> 
<head></head> 
<body> 
<form id="uploadForm" action="/PicSubmit/form" method="post" enctype="multipart/form-data" onsubmit="return submit_check()" class="bootstrap-frm" >
<input id = "sid" type = "text" name="name" />
<pre name="code" class="html"><input id = "fileImage" type = "file" name="filename" />
<input id = "addressid" type = "hidden" name="address" />
<input id="ajaxsub" type="button" class="button" value="上传图片" onclick="fileUpload()<span style="font-family: Arial, Helvetica, sans-serif;">" /> </span>
<input type="submit" class="button" value="提交表单" /> 
<input type="reset" class="button" value="重置表单" /> 

 

 
这一部分需要注意的是,form表单的enctype属性必须设置为“multipart/form-data”,在Html5中,如果需要多张图片一起上传,可以在 标签中,增加multiple属性,例如:


2 js

(1)js使用ajax提供的ajaxfileupload.js库。这个库使用起来还是比较方便的,和普通的ajax函数使用方法几乎相同。首先,需要ajaxfileupload.js库文件。这里需要注意,我之前在网上下载了一个ajaxfileupload.js文件不能用,浪费了很长时间,我直接把js库文件粘贴到这里,方便分享。

// JavaScript Document
// ajax file uplaod 
jQuery.extend({ 
  createUploadIframe: function(id, uri) 
  { 
    //create frame 
    var frameId = &#39;jUploadFrame&#39; + id; 
    if(window.ActiveXObject) { 
      var io = document.createElement(&#39;<iframe id="&#39; + frameId + &#39;" name="&#39; + frameId + &#39;" />&#39;); 
      if(typeof uri== &#39;boolean&#39;){ 
        io.src = &#39;javascript:false&#39;; 
      } 
      else if(typeof uri== &#39;string&#39;){ 
        io.src = uri; 
      } 
    } 
    else { 
      var io = document.createElement(&#39;iframe&#39;); 
      io.id = frameId; 
      io.name = frameId; 
    } 
    io.style.position = &#39;absolute&#39;; 
    io.style.top = &#39;-1000px&#39;; 
    io.style.left = &#39;-1000px&#39;; 
    document.body.appendChild(io); 
    return io; 
  }, 
  createUploadForm: function(id, fileElementId) 
  { 
    //create form 
    var formId = &#39;jUploadForm&#39; + id; 
    var fileId = &#39;jUploadFile&#39; + id; 
    var form = jQuery(&#39;<form action="" method="POST" name="&#39; + formId + &#39;" id="&#39; + formId + &#39;" enctype="multipart/form-data"></form>&#39;); 
    var oldElement = jQuery(&#39;#&#39; + fileElementId); 
    var newElement = jQuery(oldElement).clone(); 
    jQuery(oldElement).attr(&#39;id&#39;, fileId); 
    jQuery(oldElement).before(newElement); 
    jQuery(oldElement).appendTo(form); 
    //set attributes 
    jQuery(form).css(&#39;position&#39;, &#39;absolute&#39;); 
    jQuery(form).css(&#39;top&#39;, &#39;-1200px&#39;); 
    jQuery(form).css(&#39;left&#39;, &#39;-1200px&#39;); 
    jQuery(form).appendTo(&#39;body&#39;); 
    return form; 
  }, 
  ajaxFileUpload: function(s) { 
    // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout  
    s = jQuery.extend({}, jQuery.ajaxSettings, s); 
    var id = s.fileElementId; 
    var form = jQuery.createUploadForm(id, s.fileElementId); 
    var io = jQuery.createUploadIframe(id, s.secureuri); 
    var frameId = &#39;jUploadFrame&#39; + id; 
    var formId = &#39;jUploadForm&#39; + id; 
    if( s.global && ! jQuery.active++ ) 
    { 
      // Watch for a new set of requests 
      jQuery.event.trigger( "ajaxStart" ); 
    } 
    var requestDone = false; 
    // Create the request object 
    var xml = {}; 
    if( s.global ) 
    { 
      jQuery.event.trigger("ajaxSend", [xml, s]); 
    } 
    var uploadCallback = function(isTimeout) 
    { 
      // Wait for a response to come back 
      var io = document.getElementById(frameId); 
      try 
      { 
        if(io.contentWindow) 
        { 
          xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null; 
          xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document; 
        }else if(io.contentDocument) 
        { 
          xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null; 
          xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document; 
        } 
      }catch(e) 
      { 
        jQuery.handleError(s, xml, null, e); 
      } 
      if( xml || isTimeout == "timeout") 
      { 
        requestDone = true; 
        var status; 
        try { 
          status = isTimeout != "timeout" ? "success" : "error"; 
          // Make sure that the request was successful or notmodified 
          if( status != "error" ) 
          { 
            // process the data (runs the xml through httpData regardless of callback) 
            var data = jQuery.uploadHttpData( xml, s.dataType ); 
            if( s.success ) 
            { 
              // ifa local callback was specified, fire it and pass it the data 
              s.success( data, status ); 
            }; 
            if( s.global ) 
            { 
              // Fire the global callback 
              jQuery.event.trigger( "ajaxSuccess", [xml, s] ); 
            }; 
          } else 
          { 
            jQuery.handleError(s, xml, status); 
          } 
        } catch(e) 
        { 
          status = "error"; 
          jQuery.handleError(s, xml, status, e); 
        }; 
        if( s.global ) 
        { 
          // The request was completed 
          jQuery.event.trigger( "ajaxComplete", [xml, s] ); 
        }; 
        // Handle the global AJAX counter 
        if(s.global && ! --jQuery.active) 
        { 
          jQuery.event.trigger("ajaxStop"); 
        }; 
        if(s.complete) 
        { 
          s.complete(xml, status); 
        } ; 
        jQuery(io).unbind(); 
        setTimeout(function() 
        { try 
        { 
          jQuery(io).remove(); 
          jQuery(form).remove(); 
        } catch(e) 
        { 
          jQuery.handleError(s, xml, null, e); 
        } 
        }, 100); 
        xml = null; 
      }; 
    } 
    // Timeout checker 
    if( s.timeout > 0 ) 
    { 
      setTimeout(function(){ 
        if( !requestDone ) 
        { 
          // Check to see ifthe request is still happening 
          uploadCallback( "timeout" ); 
        } 
      }, s.timeout); 
    } 
    try 
    { 
      var form = jQuery(&#39;#&#39; + formId); 
      jQuery(form).attr(&#39;action&#39;, s.url); 
      jQuery(form).attr(&#39;method&#39;, &#39;POST&#39;); 
      jQuery(form).attr(&#39;target&#39;, frameId); 
      if(form.encoding) 
      { 
        form.encoding = &#39;multipart/form-data&#39;; 
      } 
      else 
      { 
        form.enctype = &#39;multipart/form-data&#39;; 
      } 
      jQuery(form).submit(); 
    } catch(e) 
    { 
      jQuery.handleError(s, xml, null, e); 
    } 
    if(window.attachEvent){ 
      document.getElementById(frameId).attachEvent(&#39;onload&#39;, uploadCallback); 
    } 
    else{ 
      document.getElementById(frameId).addEventListener(&#39;load&#39;, uploadCallback, false); 
    } 
    return {abort: function () {}}; 
  }, 
  uploadHttpData: function( r, type ) { 
    var data = !type; 
    data = type == "xml" || data ? r.responseXML : r.responseText; 
    // ifthe type is "script", eval it in global context 
    if( type == "script" ) 
    { 
      jQuery.globalEval( data ); 
    } 
    // Get the JavaScript object, ifJSON is used. 
    if( type == "json" ) 
    { 
      eval( "data = " + data ); 
    } 
    // evaluate scripts within html 
    if( type == "html" ) 
    { 
      jQuery("<p>").html(data).evalScripts(); 
    } 
    return data; 
  }, 
  handleError: function( s, xhr, status, e )   { 
    // If a local callback was specified, fire it  
    if ( s.error ) { 
      s.error.call( s.context || s, xhr, status, e ); 
    } 
    // Fire the global callback 
    if ( s.global ) { 
      (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] ); 
    } 
  } 
});


登入後複製


(2)之後呼叫ajaxfileupload.js函式庫,寫圖上傳腳本,這裡命名為ajaxfileuplaod_implement.js 


#
<p></p><pre name="code" class="javascript">function fileUpload() {  
  var inputObject = $("#fileImage").get(0); 
  if(inputObject.value == "") 
  { 
    alert("清先选择需要上传的图片"); 
    return false; 
  } 
  $.ajaxFileUpload({  
    url: &#39;/PicSubmit/pic&#39;, //服务器端请求地址  
    secureuri: false, //是否需要安全协议,一般设置为false  
    type: &#39;post&#39;, 
    fileElementId: &#39;fileImage&#39;, //文件上传域的ID  
    dataType: &#39;text&#39;, //返回值类型 一般设置为json  
    enctype:&#39;multipart/form-data&#39;,//注意一定要有该参数  
    success: function (data, status) //服务器成功响应处理函数  
    {  
      data=decodeURI(data);//服务器端使用urlencode将中文字符编码,所以这里需要解码。这样做的目的是防止中文乱码 
      var address = JSON.parse(data); 
      for(var i=0;i<address.length;i++){ 
        ajaxfile_onSuccess(address[i]); //这里的success回调函数可以自己定义,但是有一点需要注意,就是需要把服务器返回来的图片存储路径写入
<span style="white-space:pre">              </span>//hiden标签的value值中,方法见下面的writeHide函数 
      } 
    },  
    complete: function(xmlHttpRequest)  
    {<span style="white-space:pre"> </span>//这里将html中的文件上传标签替换为新的标签,是应为我在开发过程中发现,当ajax执行一次上传操作之后,再使用file标签选择文件时,标签没有反应,
<span style="white-space:pre">   </span>//所以暂时使用了这种方法。 
      inputObject.replaceWith(&#39;<input type="file" id="fileImage" name="fileImage" />&#39;); 
    }, 
    error: function (data, status, e)//服务器响应失败处理函数 
    {  
      //alert("无法连接到服务器"); 
    }  
  })  
}
function writeHide(data){ 
<span style="white-space:pre"> </span>if($("#addressid").get(0).value == "") 
<span style="white-space:pre"> </span>{ 
<span style="white-space:pre">   </span>$("#addressid").get(0).value = data.newName; 
<span style="white-space:pre"> </span>} 
<span style="white-space:pre"> </span>else 
<span style="white-space:pre"> </span>{ 
<span style="white-space:pre">   </span>$("#addressid").get(0).value = $("#addressid").get(0).value+","+data.newName; 
<span style="white-space:pre"> </span>} 
} 

3 spring.

完成上面两个部分之后,前台的主要工作基本就结束了。我后台使用了spring框架。

首先是springMVC的配置文件:viewspace-servlet.xml

<?xml version="1.0" encoding="UTF-8" ?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
    http://www.springframework.org/schema/mvc  
    http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
    http://www.springframework.org/schema/context  
    http://www.springframework.org/schema/context/spring-context-3.1.xsd"> 
  <!-- 静态资源 --> 
  <mvc:resources mapping="/js/**" location="/js/" /> 
  <mvc:resources mapping="/css/**" location="/css/" /> 
  <mvc:resources mapping="/image/**" location="/image/" /> 
  <!-- 扫描web包,应用Spring的注解 --> 
  <context:component-scan base-package="web"/> 
  <bean id="defaultAnnotationHandlerMapping" 
     class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> 
  <bean id="annotationMethodHandlerAdapter" 
     class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> 
  <!-- 配置视图解析器,将ModelAndView及字符串解析为具体的页面 --> 
  <bean 
      class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
      p:viewClass="org.springframework.web.servlet.view.JstlView" 
      p:prefix="/WEB-INF/jsp/" 
      p:suffix=".jsp"/>  
  <!-- 使springMVC支持图片上传 -->  
  <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">  
      <!-- 最大上传尺寸1MB --> 
      <property name="maxUploadSize" value="10485760"/> 
      <!-- 默认编码 --> 
      <property name="defaultEncoding" value="UTF-8" /> 
      <!-- 上传文件的解析 --> 
      <property name="resolveLazily" value="true" /> 
  </bean> 
  <!-- SpringMVC在超出上传文件限制时,会抛出org.springframework.web.multipart.MaxUploadSizeExceededException --> 
   <!-- 该异常是SpringMVC在检查上传的文件信息时抛出来的,而且此时还没有进入到Controller方法中 --> 
   <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" > 
     <property name="exceptionMappings"> 
       <props> 
         <!-- 遇到MaxUploadSizeExceededException异常时,自动跳转到/WEB-INF/jsp/error_toobig.jsp页面 --> 
         <prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">error_fileupload</prop> 
      </props> 
    </property> 
   </bean> 
</beans>
其中,类“org.springframework.web.multipart.commons.CommonsMultipartResolver”的配置是必须的,否则后台无法收到前台传来的文件。


为了防止文件名中的中文字符传输出现问题,在web.xml中做如下配置:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> 
 <context-param> 
  <param-name>contextConfigLocation</param-name> 
  <param-value>classpath:applicationContext.xml</param-value> 
 </context-param> 
 <listener> 
  <listener-class> 
      org.springframework.web.context.ContextLoaderListener 
    </listener-class> 
 </listener> 
 <servlet> 
  <servlet-name>viewspace</servlet-name> 
  <servlet-class> 
      org.springframework.web.servlet.DispatcherServlet 
    </servlet-class> 
 </servlet> 
 <servlet-mapping> 
  <servlet-name>viewspace</servlet-name> 
  <url-pattern>/</url-pattern> 
 </servlet-mapping> 
 <!-- 支持传输中文字符 --> 
 <filter>  
    <filter-name>characterEncodingFilter</filter-name>  
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
    <init-param>  
      <param-name>encoding</param-name>  
      <param-value>UTF-8</param-value>  
    </init-param>  
    <init-param>  
      <param-name>forceEncoding</param-name>  
      <param-value>true</param-value>  
    </init-param>  
  </filter>  
  <filter-mapping>  
    <filter-name>characterEncodingFilter</filter-name>  
    <url-pattern>/*</url-pattern>  
  </filter-mapping>  
</web-app>


登入後複製


接下來是重點,在Controller中,使用以下方式接受前台穿回來的檔案。
 


<pre name="code" class="java"> @RequestMapping(value="/pic") 
  @ResponseBody 
  public String submitPic(@RequestParam(value = "filename",required = false) MultipartFile[] fileImage,  
      HttpServletRequest request){ 
    if(fileImage == null){ 
      return "[]"; 
    } 
    return picSaveService.savePic(fileImage); 
  }

登入後複製


#其中需要注意的是,如果前端html的input標籤中使用了multiple屬性,則表示標籤支援上傳多個圖片,則controller的參數清單中,檔案的類型使用MultipartFile[],反之,如果沒有使用multiple屬性,表示上傳的是一張圖片,則controller使用MultipartFile類型接收。


<p><br> 
</p><p>文件接收完成后,就可以对文件进行存储了,方法有很多,我这里举一个例子如下:</p> 
<p></p><pre name="code" class="java">  public String savePic(MultipartFile[] fileImage){ 
    //为图片改名 
    String oldName = ""; 
    String newName = ""; 
    String extension = ""; 
    //图片按照上传时间命名 
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); 
    //存储每张图片的信息 
    List<PicConfirmData> resultList = new ArrayList<PicConfirmData>(); 
    //获取配置文件中图片的存储路径 
    String path = Parameters.getInstance().getDatabaseProps().getProperty("pic_save_dir"); 
    //依次将图片存储到path路径下 
    for(int i=0;i<fileImage.length;i++){ 
      System.out.println(fileImage[i].getOriginalFilename()); 
      oldName = fileImage[i].getOriginalFilename();     
      extension = oldName.substring(oldName.lastIndexOf(".")); 
      newName = sdf.format(new Date())+extension; 
      File target = new File(path,newName); 
      if(!target.exists()){ 
        target.mkdirs(); 
      } 
      try { 
          fileImage[i].transferTo(target); 
        } catch (IllegalStateException e) { 
          e.printStackTrace(); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      //记录图片存储信息 
      PicConfirmData pic = null; 
      try { 
        //只存名称,路径已知,从而节省数据库空间 
        //pic = new PicConfirmData(URLEncoder.encode(oldName, "utf-8"), path+newName); 
        pic = new PicConfirmData(1,URLEncoder.encode(oldName, "utf-8"), newName); 
        resultList.add(pic); 
      } catch (UnsupportedEncodingException e) { 
        e.printStackTrace(); 
      } 
    } 
    return ToolJson.getJsonFromPicConfirmData(resultList); 
  }
这里将接收到的图片的原始名称以及修改后存储使用的名称返回给前台,原始名称用于在前台页面输出“存储成功”的提示信息,修改后的名称用于给hiden标签复制,hiden标签的内容会在之后随表单中其他信息一起提交到服务端,通过hiden标签,我们就可以知道与表单关联的图片被存储在什么地方。

最后,图片上传完成后还需要提交表单,这里使用SpringMVC实现一个表单接收功能。这里名为address的参数,存储的就是图片的存储路径。

  @RequestMapping(value="/form") 
  public String submitForm(HttpServletRequest request){ 
    String sid = request.getParameter("name"); 
    String address = request.getParameter("address"); 
     
    if(sid != null && submiter != null && faultTime != null && message != null && address != null){ 
      if(formDataSaveService.saveForm(sid, submiter, message, address, faultTime)){ 
        return "ac"; 
      } 
    } 
    return "error"; 
  }

登入後複製


#方法二  前台切割上傳(留著後面補充)


<p><br> 
</p> 
<link rel="stylesheet" href="http://static.jb51.net/public/res-min/markdown_views.css?v=1.0"> 
           
登入後複製


#以上所述是小編給大家介紹的Ajax配合Spring實作檔案上傳功能碼,希望對大家有幫助! ! 、

相關推薦:

實例分析ajax和php實作無刷新驗證手機號碼

全面總結基於jQuery中ajax的相關方法

Ajax應該如何使用

以上是Ajax配合Spring實作檔案上傳功能碼的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

出現0x80004005錯誤代碼怎麼辦 小編教你0x80004005錯誤代碼解決方法 出現0x80004005錯誤代碼怎麼辦 小編教你0x80004005錯誤代碼解決方法 Mar 21, 2024 pm 09:17 PM

在電腦中刪除或解壓縮資料夾,時有時會彈出提示對話框“錯誤0x80004005:未指定錯誤”,如果遇到這中情況應該怎麼解決呢?提示錯誤碼0x80004005的原因其實很多,但大部分因為病毒導致,我們可以重新註冊dll來解決問題,下面,小編給大夥講解0x80004005錯誤代碼處理經驗。有使用者在使用電腦時出現錯誤代碼0X80004005的提示,0x80004005錯誤主要是由於電腦沒有正確註冊某些動態連結庫文件,或電腦與Internet之間存在不允許的HTTPS連接防火牆所引起。那麼如何

利用Spring Boot以及Spring AI建構生成式人工智慧應用 利用Spring Boot以及Spring AI建構生成式人工智慧應用 Apr 28, 2024 am 11:46 AM

Spring+AI作為行業領導者,透過其強大、靈活的API和先進的功能,為各種行業提供了領先性的解決方案。在本專題中,我們將深入探討Spring+AI在各領域的應用範例,每個案例都將展示Spring+AI如何滿足特定需求,實現目標,並將這些LESSONSLEARNED擴展到更廣泛的應用。希望這個專題能對你有所啟發,更深入地理解和利用Spring+AI的無限可能。 Spring框架在軟體開發領域已經有超過20年的歷史,自SpringBoot1.0版本發布以來已有10年。現在,無人會質疑,Spring

夸克網盤的檔案怎麼轉移到百度網盤? 夸克網盤的檔案怎麼轉移到百度網盤? Mar 14, 2024 pm 02:07 PM

  夸克網盤和百度網盤都是現在最常用的儲存文件的網盤軟體,如果想要將夸克網盤內的文件保存到百度網盤,要怎麼操作呢?本期小編整理了夸克網盤電腦端的檔案轉移到百度網盤的教學步驟,一起來看看是怎麼操作吧。  夸克網盤的檔案怎麼存到百度網盤?要將夸克網盤的文件轉移到百度網盤,首先需在夸克網盤下載所需文件,然後在百度網盤用戶端中選擇目標資料夾並開啟。接著,將夸克網盤中下載的檔案拖放到百度網盤用戶端開啟的資料夾中,或使用上傳功能將檔案新增至百度網盤。確保上傳完成後在百度網盤中查看檔案是否已成功轉移。這樣就

hiberfil.sys是什麼檔案? hiberfil.sys可以刪除嗎? hiberfil.sys是什麼檔案? hiberfil.sys可以刪除嗎? Mar 15, 2024 am 09:49 AM

  最近有很多網友問小編,hiberfil.sys是什麼文件? hiberfil.sys佔用了大量的C碟空間可以刪除嗎?小編可以告訴大家hiberfil.sys檔是可以刪除的。下面就來看看詳細的內容。 hiberfil.sys是Windows系統中的隱藏文件,也是系統休眠文件。通常儲存在C盤根目錄下,其大小與系統安裝記憶體大小相當。這個檔案在電腦休眠時被使用,其中包含了當前系統的記憶體數據,以便在恢復時快速恢復到先前的狀態。由於其大小與記憶體容量相等,因此它可能會佔用較大的硬碟空間。  hiber

PHP 與 Ajax:建立一個自動完成建議引擎 PHP 與 Ajax:建立一個自動完成建議引擎 Jun 02, 2024 pm 08:39 PM

使用PHP和Ajax建置自動完成建議引擎:伺服器端腳本:處理Ajax請求並傳回建議(autocomplete.php)。客戶端腳本:發送Ajax請求並顯示建議(autocomplete.js)。實戰案例:在HTML頁面中包含腳本並指定search-input元素識別碼。

MySQL中.ibd檔的作用詳解及相關注意事項 MySQL中.ibd檔的作用詳解及相關注意事項 Mar 15, 2024 am 08:00 AM

MySQL中.ibd檔案的作用詳解及相關注意事項MySQL是一種流行的關聯式資料庫管理系統,資料庫中的資料儲存在不同的檔案中。其中,.ibd檔案是InnoDB儲存引擎中的資料文件,用於儲存表格中的資料和索引。本文將對MySQL中.ibd檔案的作用進行詳細解析,並提供相關程式碼範例以幫助讀者更好地理解。一、.ibd檔的作用:儲存資料:.ibd檔是InnoDB存

Linux系統查看log日誌指令詳解! Linux系統查看log日誌指令詳解! Mar 06, 2024 pm 03:55 PM

在Linux系統中,可以使用下列指令來查看日誌檔案的內容:tail指令:tail指令用來顯示日誌檔案的末尾內容。它是查看最新日誌資訊的常用命令。 tail[選項][檔案名稱]常用的選項包括:-n:指定要顯示的行數,預設為10行。 -f:即時監視文件內容,並在文件更新時自動顯示新的內容。範例:tail-n20logfile.txt#顯示logfile.txt檔案的最後20行內容tail-flogfile.txt#即時監視logfile.txt檔案的更新內容head指令:head指令用於顯示記錄檔的開頭

建立並執行Linux'.a”文件 建立並執行Linux'.a”文件 Mar 20, 2024 pm 04:46 PM

在Linux作業系統中處理檔案需要使用各種命令和技術,使開發人員能夠有效率地建立和執行檔案、程式碼、程式、腳本和其他東西。在Linux環境中,擴展名為”.a”的檔案作為靜態庫具有重要的重要性。這些程式庫在軟體開發中發揮重要作用,允許開發人員有效地管理和共享多個程式的公共功能。對於Linux環境中的有效軟體開發,了解如何建立和運行「.a」檔案至關重要。本文將介紹如何全面安裝和設定Linux「.a」文件,讓我們一起探索Linux「.a」文件的定義、用途、結構,以及建立和執行它的方法。什麼是L

See all articles