file-type

What's the easiest and quickest way to get the MIME/Media/Content type of a given URL?

我与影子孤独终老i 提交于 2019-12-31 05:40:33
问题 So I'm going to transfer a file from a remote server to my server but before I transfer it I want to know what sort of file it is. If it's an HTML file I'll deal with it in a certain way, if it's a PDF file I'll deal with it in a different way, and if, for instance, it's an exe file, I don't want to transfer it at all. All I've got to go on is a URL. Now if that URL is explicit (i.e. http://example.com/file.pdf) it's not a problem, I can just check the file extension and we're sorted. However

How to identify doc, docx, pdf, xls and xlsx based on file header

跟風遠走 提交于 2019-12-30 03:03:10
问题 How to identify doc, docx, pdf, xls and xlsx based on file header in C#? I don't want to rely on the file extensions neither MimeMapping.GetMimeMapping for this as either of the two can be manipulated. I know how to read the header but dont know what combination of bytes can say if a file is a doc, docx, pdf, xls or xlsx. Any thoughts? 回答1: This question contains a example of using the first bytes of a file to determine the file type: Using .NET, how can you find the mime type of a file based

Determine file type in C

给你一囗甜甜゛ 提交于 2019-12-29 07:12:28
问题 I am working on a program in C on a linux machine that displays the file type of a file presented as an argument to the program. The program needs to determine if a file is any one of the following: directory, device, (regular) file, link, socket, or fifo. I am not exactly sure how to determine file type. Here is my code thus far (not much): int main(int argc, char **argv) { if( argc == 1 ) /* default: current directory */ puts("Directory"); else while( --argc > 0 ) determine_ftype(*++argv);

Webstorm not recognising JavaScript file

£可爱£侵袭症+ 提交于 2019-12-28 11:41:29
问题 Webstorm doesn't recognize one of my .js files as a JavaScript file so I'm losing syntax highlighting and being able to add break points. I've looked in the workspace.xml file and the file in question seems to have similar settings to other .js files that work correctly. If I change the name of the file it works ok. So somehow Webstorm is stuck on misinterpreting the type of a file that has this name. Where else can I edit the project? 回答1: So I see three possible reasons of the problem: 1)

How to get file name from content-disposition

蓝咒 提交于 2019-12-28 05:48:05
问题 I Downloaded file as response of ajax. How to get file name and file type from content-disposition and display thumbnail for it. i got many search results but couldn't find right way. $(".download_btn").click(function () { var uiid = $(this).data("id2"); $.ajax({ url: "http://localhost:8080/prj/" + data + "/" + uiid + "/getfile", type: "GET", error: function (jqXHR, textStatus, errorThrown) { console.log(textStatus, errorThrown); }, success: function (response, status, xhr) { var header = xhr

How to accurately determine mime data from a file?

拜拜、爱过 提交于 2019-12-28 05:30:07
问题 I'm adding some functionality to a program so that I can accurately determine the files type by reading the MIME data. I've already tried a few methods: Method 1: javax.activation.FileDataSource FileDataSource ds = new FileDataSource("~\\Downloads\\777135_new.xls"); String contentType = ds.getContentType(); System.out.println("The MIME type of the file is: " + contentType); //output = The MIME type of the file is: application/octet-stream Method 2: import net.sf.jmimemagic.*; try {

How to check is upload file is CSV or XLS

大城市里の小女人 提交于 2019-12-25 04:38:24
问题 I upload CSV or XLS file and import that file content in to the data base. There is two separate method for read CSV and XLS file read( readCSV() and readXLS() ). when i upload CSV or XLS file that gave to me same file type if(file_type($my_file) =='CSV'){ readCSV(); }else{ readXLS(); } How can i write file_type() function for get separate result for CSV and XLS files 回答1: <?php $chunks = basename($your_file_path).explode('.'); if(strtolower($chunks[count($chunks)-1]) == 'csv'){ //csv }else{

Uploadify refuses to upload WMV, FLV and MP4 files

旧时模样 提交于 2019-12-24 10:59:03
问题 The uploadify plugin for JQuery seems very good and works for most file types. However, it allows me to upload all file types apart from the ones I need. Uploads of any other type work. I have already tried changing the fileExt parameter and also tried removing it altogether. I have testing in Google Chrome, IE7 and Firefox and none work for these file types. I have a ton of local projects already and uploading is not an issue on any other project, I even use the same example files (This is

How to delete ProgIDs from other user accounts when uninstalling from Windows?

大城市里の小女人 提交于 2019-12-24 10:34:34
问题 I've been investigating "how should a modern windows c++ application register its file types" with Windows (see C++: How do I correctly register and unregister file type associations for our application (programatically)). And having combed through the various MSDN articles on the subject, the summary appears to be as follows: The installer (elevated) should register the global ProgID HKLM\Software\Classes\my-app.my-doc[.version] (e.g. HKLM\Software\Classes\TextPad.text) The installer also

how do I get emacs to treat a file with the wrong extension correctly?

故事扮演 提交于 2019-12-24 06:01:31
问题 So (let us not concern ourselves with why) I have a .emacs file which is called dotemacs , and a .bashrc file which is called dotbashrc . When I load up dotemacs , I get no syntax highlighing (amongst other things). If I do M-x lisp-mode then all is well. Without changing the name of the file, how do I get emacs to recognise automatically that dotemacs is a lisp file and go into lisp-mode ? Similarly for bash scripts, and indeed any other type of file with the wrong (or no) extension. 回答1: