file-type

Grails file upload - how to recognize file and/or content type?

时光怂恿深爱的人放手 提交于 2020-01-22 12:18:07
问题 I'm a Grails beginner, so please be patient with me. Currently I'm having hard times manipulating file uploads. As far as I understand using request.getFile() I can easily get the stream of bytes. But before I do that, I want to check the following: file name of the file being uploaded file size of the file being uploaded content/file type of the file being uploaded How can this be done? Is it even possible before the file is uploaded to the server? I would like to block uploading of large

How do I tell if someone's faking a filetype? (PHP)

南楼画角 提交于 2020-01-12 04:50:08
问题 I'm programming something that allows users to store documents and pictures on a webserver, to be stored and retrieved later. When users upload files to my server, PHP tells me what filetype it is based on the extension. However, I'm afraid that users could rename a zip file as somezipfile.png and store it, thus keeping a zip file on my server. Is there any reasonable way to open an uploaded file and "check" to see if it truly is of the said filetype? 回答1: Magic number. If you can read first

svn diff: file marked as binary type

本秂侑毒 提交于 2020-01-11 15:00:05
问题 I'm doing an svn diff on one of my files and svn is detecting it as a binary type. The file is readable plain text and I would like to be able to get a diff of this file. How do I tell SVN that this is not a binary file? Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream 回答1: You can use the Subversion property svn:mime-type to set an explicit mimetype on the file: svn propset svn:mime-type 'text/plain' path/to/file Alternatively, you can delete this

svn diff: file marked as binary type

白昼怎懂夜的黑 提交于 2020-01-11 14:59:48
问题 I'm doing an svn diff on one of my files and svn is detecting it as a binary type. The file is readable plain text and I would like to be able to get a diff of this file. How do I tell SVN that this is not a binary file? Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream 回答1: You can use the Subversion property svn:mime-type to set an explicit mimetype on the file: svn propset svn:mime-type 'text/plain' path/to/file Alternatively, you can delete this

PHP File Type Restrictions

我的梦境 提交于 2020-01-05 10:13:22
问题 I am trying out PHP my first actual script, most of it from tutorial :( Anyway's I am having a problem on this part // This is our limit file type condition if (!($uploaded_type=="text/java")||!($uploaded_type=="file/class")||!($uploaded_type=="file/jar")) { echo "You may only upload Java files.<br>"; $ok=0; } Basically it doesn't allow any files, even those up there help! I want the Java files to be allowed only! EDIT: Here is the full code <?php $target = "upload/"; $target = $target .

Nodejs, to get file type of a file

浪子不回头ぞ 提交于 2020-01-04 03:18:30
问题 The six-year-old question "Node.js - File System get file type, solution around year 2012" has a better answer but the outdated answer was the correct one by then. Hence the question, for an up-to-date solution. 回答1: OPTION 1: If you want the mimetype : Install npm i -S file-type read-chunk Use const readChunk = require('read-chunk'); const fileType = require('file-type'); const buffer = readChunk.sync(filePath, 0, fileType.minimumBytes); console.log(fileType(buffer)); OPTION 2: If you just

Nodejs, to get file type of a file

不羁岁月 提交于 2020-01-04 03:18:18
问题 The six-year-old question "Node.js - File System get file type, solution around year 2012" has a better answer but the outdated answer was the correct one by then. Hence the question, for an up-to-date solution. 回答1: OPTION 1: If you want the mimetype : Install npm i -S file-type read-chunk Use const readChunk = require('read-chunk'); const fileType = require('file-type'); const buffer = readChunk.sync(filePath, 0, fileType.minimumBytes); console.log(fileType(buffer)); OPTION 2: If you just

SVN Diff: Why are some files marked as binary

落爺英雄遲暮 提交于 2020-01-02 00:53:13
问题 Directly related: svn diff: file marked as binary type (Per the comment on the answer) Why would my SVN client mark some files as binary? Specifically, .sql has prop svn:mime-type = application/octet-stream when using TortoiseSVN. I checked Right-click > Tortoise context menu > Settings > General > Subversion configuration file, and nothing is uncommented in [miscellany] or [auto-props] , so where is the decision coming from? From what I can see in the related posts, I can "fix it" by either

How to detect the uploaded file type in angularJS

时间秒杀一切 提交于 2020-01-01 10:01:23
问题 I have an form to upload only image file using angularJS. Uploading the file is all working fine. The problem is, I want to restrict the uploaded file to be only image file and also the size of the image to be some MB. How can I achieve this using only angularJS? Below is the code $scope.uploadFile = function(files) { var fd = new FormData(); //Take the first selected file fd.append("file", files[0]); $http.post("logoTypesServiceStore", fd, { withCredentials: true, headers: {'Content-Type':

How can I get the Name of the Program associated with a file extension using Delphi?

柔情痞子 提交于 2020-01-01 02:44:58
问题 I need to get the name of the program currently associated with a file extension for the current user. If you right-click on a file and select properties, then what I need is the program name that is to the right of the "Opens with" line. e.g. For ".xls", I want to be able to get the answer "Microsoft Office Excel", or whatever program the user has as their default program to open .xls files. I have determined it's not as easy as just going into HKEY_CLASSES_ROOT and picking it out, since it