NameSilo

This is a really noobish question...

Spaceship Spaceship
Watch

Barrucadu

Established Member
Impact
64
On my image hosting site they're is a 1MB filesize limit, the script I use to check that is:

PHP:
//Check the size
if(!filesize($_FILES['uploadedfile']['name']) <= 1000000){
	echo "File too large!"
	echo "<p>Maximum size is 1MB</p>"
	die("")
}

1st question: are there 1,000,000 bytes in a megabyte
2nd question: would that work?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
there are 1048576 bytes in 1mb

and die("") I dont think will work use die();

PHP:
//Check the size
if(!filesize($_FILES['uploadedfile']['name']) <= 1048576){
    echo "File too large!";
    echo "<p>Maximum size is 1MB</p>";
    die();
}
 
0
•••
You can use double quotes in the DIE() function ;)

Wont affect anything. They are actually suppossed to be used for a message inside of the DIE() function
 
0
•••
Yeah, but there's no point, it's just extra typing.
 
0
•••
compuXP said:
Yeah, but there's no point, it's just extra typing.

You can certainly use is as:

die();

or

die("");

Quotes can be most useful to report back an error to the surfer if you want. I do this all the time when I write code for inept end-users. I will display a SPECIFIC error that I can trace back to the exact line in the code.

For example, if you are trying to open a file and it fails, you can always report the error something like this:

PHP:
<?
  $infile = fopen('file.txt','r');
  if(!$infile) {die("Error Opening File");}
?>

-Bob
 
0
•••
well, yeah, but first an ugly error would appear - you'd want the @ character in the line.
 
0
•••
or

error_reporting(0); :)
 
0
•••
I rather use exit; :S

Also... i dont usually use those types of functions unless i cant use a if/else combo :-/ its better to me...
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back