發表文章

angular ajax file upload

請看程式上面的注解囉。 找資料很困難,查到怎麼做還蠻簡單=_= HTML <input id="file" name="file" type="file"  /> <input type="button" value="上傳2" ng-click="upload()"/> JS(Controller)  //檔案上傳函數 $scope.upload = function () {   //取得所選的上傳檔案 var file = document.getElementById('file').files[0];   //使用formData去包資料 var formData = new FormData();   //input name , 檔案/資料 formData.append("file", file); $http({  method: 'POST',  url: "Pathangul",  headers: {'Content-Type': undefined},  data: formData }).success(function (data) {  console.log(data); }).error(function () {  alert("error"); }); };

Angularjs Dynamic From Action

In Controller   document. Form .action = 'http://www.example.com/API/Purchase'; In Html <form name=" Form ">  ... </form> then it should work

[jersey]Download file from Remote Server

從其他網站伺服器下載範例 import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @Path("/Purchase") public class File {     @GET   @Path("File/{FileName}")   @Produces(MediaType.APPLICATION_OCTET_STREAM + "; charset=UTF-8")   public Response getFile2(           @PathParam("FileName") String FileName   ) throws MalformedURLException, IOException  {     //遠端取檔案下載     URL url = new URL("http://www.example.com/files/" + FileName);     URLConnection uc = url.openConnection();     Response.ResponseBuilder response = Response.ok((Object) uc.getInputStream());     response.header("Content-Disposition", "attachment; filename=" + FileNam...

[API Server]jersey 檔案多檔上傳

1. POM     <dependency>       <groupId>org.glassfish.jersey.containers</groupId>       <artifactId>jersey-container-servlet</artifactId>       <version>2.17</version>     </dependency>       <dependency>       <groupId>org.glassfish.jersey.containers</groupId>       <artifactId>jersey-container-servlet-core</artifactId>       <version>2.17</version>     </dependency>     <dependency>       <groupId>org.glassfish.jersey.media</groupId>       <artifactId>jersey-media-multipart</artifactId>       <version>2.17</version>     </dependency> 2.上傳網頁 <html>   <head>     <title<TODO supply a title</title>   ...

[API Server]jersey 檔案上傳

1. POM           org.glassfish.jersey.containers       jersey-container-servlet       2.17                  org.glassfish.jersey.containers       jersey-container-servlet-core       2.17               org.glassfish.jersey.media       jersey-media-multipart       2.17     2.上傳網頁 <html>   <head>     <title>TODO supply a title</title>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">   </head>   <body>     <form action="API/file/upload" method="post" enctype="multipart/form-data" >       <p>         Select a file : <input type="file" name="file" />  ...

[angularjs]Error: $compile:multidir Multiple Directive Resource Contention 解決方式

官方文件 https://docs.angularjs.org/error/$compile/multidir 官方文件上說的事你宣告了兩個相同定義的directive 問題出在 directive   restrict: 'AE' 例如 這時候region跟school的directive定義為AE 那麼在學校tag也有個region他就傻傻分不清楚就壞掉囉OTZ 解決的方式是將directive的restrict改為E(Element)定義   restrict: 'E' 就可以解決重複定義的問題

[web] 網頁圖片 CSS Sprites、DataURI、Web Font 簡單比較及工具

CSS Sprites, DataURI 和 Icon-fonts 這三者都 可以用於網頁小圖示上。 這三者都可以用於減少網頁上的 request ,使網頁變快一些。 下列式分析 CSS Sprites 概述 : 就是把所有的小圖示變成一張大圖,再利用 CSS 定位方式去找到該圖片並顯示 優點 : 圖片可彩色 缺點 : 大小固定,重新作大圖很麻煩,維護不易 瀏覽器 : IE8+ 工具網站 : http://csssprites.com/ DataURI 概述 : 將圖片已 base64 作編碼,網站便會將他解譯成圖片 優點 : 圖片可彩色,不需再建立連線拉圖片 缺點 :IE8+ (IE8 有限制 32KB 大小 ) 工具網站 : http://www.base64-image.de/ Web Font 概述 : 字型本身就是圖案,所以利用字型檔 (ttf/woff/eot) 將圖片放置在對應的文字內 優點 : 因轉成文字,所以可以對圖片下 CSS( 但 CSS 仍受該 CSS 是否支援瀏覽器影響 ) 缺點 : 單色 工具網站 : http://icomoon.io/app/#/select