PDA

View Full Version : Using filesize


Reaver
02-03-2002, 02:17 PM
I'm making a downloads page for a client, which on the admin end has a form that you fill out, among other things, the path to the file. I used the filesize statement to get the size of the file and add it to the DB along with the other information, but here's the problem:

As far as I know, filesize() only works with a local server path. That's fine with me, but when I go to post the link on an HTML page, of course a local path won't work.

So I tried the following:
$size = filesize('/home/pcfxcc/public_html/$path');


Where $path would be what the user entered. I thought I could just append the local server address onto the path variable just for the filesize, and simply use $path alone when it grabs it for the HTML page, but it didn't work. Is there any way around this?


Also, filesize returns the size in bytes, which is rather ugly. Is there any easy way to convert that into something more friendly, like 1.1MB, etc?

Thanks :)

Reaver
02-03-2002, 02:24 PM
Ahh, nevermind about the first part, in the filesize() statement I just changed the ' to " and it worked :)

I'm still stumped about the second part though, about the display of the filesize.

DCE
02-03-2002, 02:38 PM
Try a search at PHPBuilder like this one (http://www.phpbuilder.com/search/?config=forum;format=;words=filesize%20mb;page=2)
There's quite a few threads there that look relevant.

Reaver
02-04-2002, 01:07 AM
Thanks DCE, I found what I was looking for :)