| 
									
										
										
										
											2014-10-25 14:58:32 +08:00
										 |  |  | # `File` object
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-26 16:41:25 -07:00
										 |  |  | The DOM's File interface provides abstraction around native files in order to | 
					
						
							| 
									
										
										
										
											2015-08-25 05:48:24 -07:00
										 |  |  | let users work on native files directly with the HTML5 file API. Electron has | 
					
						
							| 
									
										
										
										
											2015-08-26 16:41:25 -07:00
										 |  |  | added a `path` attribute to the `File` interface which exposes the file's real | 
					
						
							|  |  |  | path on filesystem. | 
					
						
							| 
									
										
										
										
											2014-10-25 14:58:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-25 05:48:24 -07:00
										 |  |  | Example on getting a real path from a dragged-onto-the-app file: | 
					
						
							| 
									
										
										
										
											2014-10-25 14:58:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```html | 
					
						
							|  |  |  | <div id="holder"> | 
					
						
							|  |  |  |   Drag your file here | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  |   var holder = document.getElementById('holder'); | 
					
						
							|  |  |  |   holder.ondragover = function () { | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   holder.ondragleave = holder.ondragend = function () { | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   holder.ondrop = function (e) { | 
					
						
							|  |  |  |     e.preventDefault(); | 
					
						
							|  |  |  |     var file = e.dataTransfer.files[0]; | 
					
						
							|  |  |  |     console.log('File you dragged here is', file.path); | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | ``` |