English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Am I suppose to set the “file” and the “size” before I use the following, like is “file” a php thing or do I use a name of something?

This is what I’m asking about:

if($_FILES["file"]["size"] > 1000000){
}



Same question about the following:

else {
// everything was ok, so attempt to upload it
if(move_uploaded_file($_FILES["file"]["tmp_name"], $target)){

$date = date("D dS M,Y");
$time = date("h:i a");

print "The file has been uploaded!";
print $date " ";
print $time "
";
print "
Upload: " . $_FILES["file"]["name"];
print "
Type: " . $_FILES["file"]["type"];
print "
Size: " . $_FILES["file"]["size"];
print "
Stored In: " . $_FILES["file"]["tmp_name"];

$fs = fopen("txt/uploadhistory.txt", "a");
$fputs($fs, $data);
$fclose ($fs);

}


The only names that I got so far are:
$date
$time
$xname
$desc
$file

Should I create a $size, $type, $tmp_name and define them or what since those are being used in the $_FILES[“ ”][“ ”]; thingy?

2007-03-17 10:15:01 · 1 answers · asked by Am 4 in Computers & Internet Programming & Design

Oh come on y don't any1 ans my PHP q's it's been 30 min, I know they're PHP heads up in Y!Answers, so where yall @?!? Forums take like days or weeks that's y I'm in Y!Answers yall, PLEASE ans my Q?!?!?!

2007-03-17 10:50:58 · update #1

1 answers

this script The user may only upload .gif or .jpeg files and the file size must be under 20 kb:

if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
}
else
{
echo "Invalid file";
}

?>

2007-03-17 11:35:17 · answer #1 · answered by Anonymous · 1 0

fedest.com, questions and answers