file-extension

“Bad” file extensions that should be avoided on a file upload site?

 ̄綄美尐妖づ 提交于 2019-12-05 06:57:53
Im re-writing a file hosting site, and I want to have the ability to host every single file type (instead of just having a whilelist of allowed extensions). Im running nginx and linux. Site is built in php. I'd disable th upload of .php files.... but other than that.... is there anything else I should watch out for? Here's a list of the extensions we tend to block on our php file upload system. 1st you would be best to save the files in a none accessible folder that way no one can run any files uploaded and second do a force download of every file, that way it can't be opened either. Extension

Overlap between Objective-C and MATLAB/Octave file extensions

丶灬走出姿态 提交于 2019-12-05 02:07:29
问题 Do Objective-C or MATLAB/Octave have source file extensions besides .m ? I ask because I'm putting Hello World programs in a single folder and I can't have two hello.m files. 回答1: A workaround would be to use .mm for Objective-C. .mm is used for Objective-C++ source files and it is a superset of Objective-C so it should compile fine. This is by no mean a clean solution. A much better way would be to reorganize your folder into subfolders as suggested by Ruddy Velthuis, or simply to call your

how to check file exists and get file size by substring?

﹥>﹥吖頭↗ 提交于 2019-12-04 22:09:58
I have a directory will create every day file like '2018-08-14-9-22-4', the file name created is by yyyy-mm-dd-h-m-s, how to check file is exists by substring like '2018-08-14' ? and get the file full name and file size ? my $file = "$yy-$mm-$dd-$hh-$mm-$ss"; my $path = '/home/httpd/doc/$user/$year/[every day file]' Simplest way would be to use the pattern matching in glob , and then use stat on the file. for my $name ( glob('2018-08-14-*') ) { my $size = ( stat($name) )[7]; say "name is '$name', size is $size bytes"; } or better yet... use File::stat use File::stat; for my $name ( glob('2018

How to search for files on phone sdcard or else where

僤鯓⒐⒋嵵緔 提交于 2019-12-04 21:49:54
问题 I want to search for files on the users mobile with specific extensions. I tried searching but could not find any direct API's. Is there a specific API's or is there tedious way of achieving the same. Or is there a mechanism to call linux calls for find or something similar Thanks 回答1: You can find the user's SD card via Environment.getExternalStorageDirectory() , which you can then traverse to find what you need. 回答2: boolean isSDPresent = Environment.getExternalStorageState() .equals

Is it possible to get a file extension without knowing it?

限于喜欢 提交于 2019-12-04 18:45:15
问题 I have a file called 94bf663a100e848fb599209af8cdc2b5.wmv. I know pathinfo will not give me the extension if I just use the name 94bf663a100e848fb599209af8cdc2b5. I believe glob is only for checking if a file exists. So is it possible to get a file extension just knowing the file name (94bf663a100e848fb599209af8cdc2b5)? 回答1: As the example on the php glob manual page suggests, glob does not simply check if the file exists, it returns every file that matches the expression. Here's a

SPLFileInfo: get filename without extension

有些话、适合烂在心里 提交于 2019-12-04 17:54:50
问题 I'm accessing a number of files in the SPLFileInfo object. I see a way to get the path, filename, and even extension of the file. Is there a way to get the filename without extension? Here's the code I've been working with but I'm hoping to get something more elegant. Is there an out of the box solution? $file = new SplFileInfo("path/to/file.txt.zip"); echo 'basename: '.$file->getBasename(); echo PHP_EOL; echo 'filename: '.$file->getFilename(); echo PHP_EOL; echo 'extension: '.$file-

Is Ecplise CDT's indexer limited to the common filetypes for sources and headers?

匆匆过客 提交于 2019-12-04 17:45:34
I'm working on a project while involves TOM files (.t extension), which get compiled into .c files. Now, I've told my Eclipse to treat them like C sources files, but the CDT indexer doesn't seem to want to touch them. Is it possible to tell it to consider additional filetypes? Note: TOM files look just like C files but with some additional syntax, which would just look like syntax errors on some lines to the indexer. The easiest way to do this is define a new association. To do this on your project, open Project Properties -> C/C++ General -> File Types , then select Use Project Settings and

Javascript - get extension from base64 image

纵然是瞬间 提交于 2019-12-04 16:56:08
问题 I have a base64 encoded image returned from a service and it looks like this: /9j/4AAQSkZJRgABAQEASABIAAD/4Yp2aHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/Pgo8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA0LjEtYzAzNiA0Ni4yNzcwOTIsIEZyaSBGZWIgMjMgMjAwNyAxNDoxNjoxOCAgICAgICAgIj4KICAgPHJkZjpSREYgeG1.... etc How can i detect / check the image extension? 回答1: For a String (which you can parse out of an

How to save (all) SQL server image datatype to file system with correct file extension

只愿长相守 提交于 2019-12-04 16:29:16
I have different types of files in table (txt, doc, jpg, etc) and I want to save them all to my file system. I know how to do it file by file, but it's no use, I have to do a loop that saves all files with right extensions at once. Any advice? I do it this way now: DECLARE @ObjectToken INT EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT EXEC sp_OASetProperty @ObjectToken, 'Type', 1 EXEC sp_OAMethod @ObjectToken, 'Open' EXEC sp_OAMethod @ObjectToken, 'Write', NULL, <this is where binary data goes> EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, 'd:/file.txt', 2 EXEC sp_OAMethod

Is there a new Java 8 way of retrieving the file extension?

China☆狼群 提交于 2019-12-04 16:05:05
问题 What I did up until now is following: String fileName = "file.date.txt"; String ext = fileName.substring(fileName.lastIndexOf('.') + 1); System.out.printf("'%s'%n", ext); // prints: 'txt' Is there a more convenient way in Java 8? 回答1: No, see the changelog of the JDK8 release 回答2: No there is no more efficient/convenient way in JDK, but many libraries give you ready methods for this, like Guava: Files.getFileExtension(fileName) which wraps your code in single method (with additional