filesize

Finding file's size

拥有回忆 提交于 2019-11-26 18:01:04
问题 In my iPhone app I am using the following code to find a file's size. Even though the file exists, I am seeing zero for the size. Can anyone help me? Thanks in advance. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *URL = [documentsDirectory stringByAppendingPathComponent:@"XML/Extras/Approval.xml"]; NSLog(@"URL:%@",URL); NSError *attributesError = nil; NSDictionary

Check file size before upload

一笑奈何 提交于 2019-11-26 17:26:45
I am using this javascript that I got from here, and it works perfectly for what I need it to. var _validFileExtensions = [".jpg", ".jpeg"]; function File_Validator(theForm){ var arrInputs = theForm.getElementsByTagName("input"); for (var i = 0; i < arrInputs.length; i++) { var oInput = arrInputs[i]; if (oInput.type == "file") { var sFileName = oInput.value; var blnValid = false; for (var j = 0; j < _validFileExtensions.length; j++) { var sCurExtension = _validFileExtensions[j]; if (sFileName.substr(sFileName.length - sCurExtension.length, sCurExtension.length).toLowerCase() == sCurExtension

Get size of file requested via ajax

安稳与你 提交于 2019-11-26 16:29:53
问题 Here's what I'm hoping to do: I want to send an ajax request to a file (preferably with jQuery), and once the file has been loaded, determine the size of the requested file. After a bit of googling, it's clear that I don't even have a good idea of the right question to ask to figure this out. Any help would be greatly appreciated. 回答1: You could make a HTTP HEAD request, and get a file size approximate by reading the Content-Length HTTP Header. This kind of request is used to obtain meta

Get size of file on disk

佐手、 提交于 2019-11-26 16:04:46
var length = new System.IO.FileInfo(path).Length; This gives the logical size of the file, not the size on the disk. I wish to get the size of a file on the disk in C# (preferably without interop ) as would be reported by Windows Explorer. It should give the correct size, including for: A compressed file A sparse file A fragmented file This uses GetCompressedFileSize, as ho1 suggested, as well as GetDiskFreeSpace, as PaulStack suggested, it does, however, use P/Invoke. I have tested it only for compressed files, and I suspect it does not work for fragmented files. public static long

Find size of file behind download link with jQuery

旧时模样 提交于 2019-11-26 15:19:50
I was wondering if there was a way to use jQuery to find out the file size for a PDF that i'm linking to a webpage. I want to make it so that on hovering over the download link, a modal box pops up saying the file size of the PDF. I can do the second bit, the only thing i'd like to know is how to find out the file size. I dont know if jQuery is capable of this. If not then too bad i guess.. Cheers in advance. I feel like this is too much to be doing client-side, but I don't know the details of your application, so presuming you have to do it with jQuery... you can do a HEAD request and look at

PHP filesize reporting old size

杀马特。学长 韩版系。学妹 提交于 2019-11-26 14:23:17
问题 The following code is part of a PHP web-service I've written. It takes some uploaded Base64 data, decodes it, and appends it to a file. This all works fine. The problem is that when I read the file size after the append operation I get the size the file was before the append operation. $fileOut = fopen($filepath.$filename, "ab") fwrite($fileOut, base64_decode($data)); fflush($fileOut); fclose($fileOut); $newSize = filesize($filepath.$filename); // gives old file size What am I doing wrong?

Converting file size in bytes to human-readable string

前提是你 提交于 2019-11-26 12:34:54
问题 I\'m using this function to convert a file size in bytes to a human-readable file size: function getReadableFileSizeString(fileSizeInBytes) { var i = -1; var byteUnits = [\' kB\', \' MB\', \' GB\', \' TB\', \'PB\', \'EB\', \'ZB\', \'YB\']; do { fileSizeInBytes = fileSizeInBytes / 1024; i++; } while (fileSizeInBytes > 1024); return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i]; }; However, it seems like this isn\'t 100% accurate. For example: getReadableFileSizeString(1551859712); /

why is the output of `du` often so different from `du -b`

ε祈祈猫儿з 提交于 2019-11-26 12:27:07
问题 why is the output of du often so different from du -b ? -b is shorthand for --apparent-size --block-size=1 . only using --apparent-size gives me the same result most of the time, but --block-size=1 seems to do the trick. i wonder if the output is then correct even, and which numbers are the ones i want? (i.e. actual filesize, if copied to another storage device) 回答1: Apparent size is the number of bytes your applications think are in the file. It's the amount of data that would be transferred

Find size of file behind download link with jQuery

自作多情 提交于 2019-11-26 12:15:25
问题 I was wondering if there was a way to use jQuery to find out the file size for a PDF that i\'m linking to a webpage. I want to make it so that on hovering over the download link, a modal box pops up saying the file size of the PDF. I can do the second bit, the only thing i\'d like to know is how to find out the file size. I dont know if jQuery is capable of this. If not then too bad i guess.. Cheers in advance. 回答1: I feel like this is too much to be doing client-side, but I don't know the

File-size format provider

邮差的信 提交于 2019-11-26 11:56:35
问题 Is there any easy way to create a class that uses IFormatProvider that writes out a user-friendly file-size? public static string GetFileSizeString(string filePath) { FileInfo info = new FileInfo(@\"c:\\windows\\notepad.exe\"); long size = info.Length; string sizeString = size.ToString(FileSizeFormatProvider); // This is where the class does its magic... } It should result in strings formatted something like \" 2,5 MB \", \" 3,9 GB \", \" 670 bytes \" and so on. 回答1: I use this one, I get it