0

I'm using PHP on XAMPP with Windows 10:

I have a local page in which I need to read the file size of all videos in a folder.

Until now I used the filesize() function:

filesize("_video_/".$file)

For videos larger than 2Gb, this function, returns a negative value so I found a solution online where you can just add (4*1024*1024*1024)to the result and everything worked well.

Now I've a video larger than 10Gb and the result isn't right. It is a positive number but it's a lot smaller than the real one.

Are there ways to do that?

halfer
  • 19,824
  • 17
  • 99
  • 186
G. Threepwood
  • 454
  • 8
  • 23
  • Not used it myself, but a colleague showed me this in the past and might be what you need: https://gist.github.com/mattvot/877c518f5545b2844433 ... I don't think i twas tested with 10gb plus files by my colleague though – Adam Sep 06 '18 at 15:57
  • Maybe overkill for what you're doing but this looks relevant: https://github.com/jkuchar/BigFileTools – Royal Wares Sep 06 '18 at 15:58
  • Sounds like you're on a 32-bit operating system or using a 32-bit build of PHP. Can you check using `phpinfo()`? – halfer Sep 06 '18 at 16:03
  • Dammeul & Alexander I'm gonna try your suggestions, thank you! @halfer yes it's a 32bit build of php but the system is 64 bit.Is it possible to upgrade it without reinstalling xampp? Using php 64 bit will solve the problem? Thank you! – G. Threepwood Sep 07 '18 at 10:45
  • Yes, I believe that upgrading to 64-bit PHP would solve it. Try this on a non-live server first, of course. – halfer Sep 07 '18 at 11:22
  • I should think, in relation to your reinstall question, that it would be a fresh install. 64-bit PHP will be completely different binaries (but you can use the same `php.ini`). – halfer Sep 07 '18 at 11:31
  • (Incidentally, if you are having troubles with getting your code to work on particular environments, take a look at Docker on Linux. Your app becomes indivisible from the environment you're running in, meaning there's much less chance for a surprise when you move to staging/live.) – halfer Sep 07 '18 at 11:44
  • Unfortunately it doesn't exist a 64bit version of xampp for windows :( – G. Threepwood Sep 07 '18 at 12:39
  • That appears to be true. You can just install the things separately, then - [PHP is here](https://windows.php.net/download/) and has two 64-bit releases for PHP 7.2. – halfer Sep 07 '18 at 12:54
  • I tried to download it and link it to xampp in httpd.conf but apache doesn't start and I can't find a guide about how to link another installation of php to xampp. – G. Threepwood Sep 10 '18 at 07:21
  • Ok I solved it using Alessandro Marinuzzi's answer: https://stackoverflow.com/questions/5501451/php-x86-how-to-get-filesize-of-2-gb-file-without-external-program?noredirect=1&lq=1 For now it seems to work. – G. Threepwood Sep 10 '18 at 15:13

0 Answers0