I am having difficulty checking the file size of a file before it is uploaded to the server.
What I want to do when the user clicks the 'UPLOAD' button is check the file size and then either continue and upload the file or display and error.
I cannot seem to get the file size until the file has been uploaded?
Any help much appreciated.
Code follows ...
print ("$File_size");
if ($File)
{
print ("<font face=\"MS Sans Serif\"><font color=\"#000000\"><b>File name:</b> $File_name</font><P>\n");
print ("<font face=\"MS Sans Serif\"><font color=\"#000000\"><b>File size:</b> $File_size</font><P>\n");
if (filesize($File) >25600)
{
print ("<font face=\"MS Sans Serif\"><font color=\"#000000\"><b>File Is Too Large To Be Uploaded.</b><P>\n");
}
/*else
{
if (copy ($File, "../images/$File_name"))
{
print ("<font face=\"MS Sans Serif\"><font color=\"#000000\"><b>File Was Successfully Uploaded.</b><P>\n");
}
else
{
print ("<font face=\"MS Sans Serif\"><font color=\"#000000\"><b>An Error Occurred - File Could NOT Be Uploaded.</b><P>\n");
}
}*/
unlink ($File);
}
print ("<FORM ACTION=\"FileUpload.php\" METHOD=POST ENCTYPE=\"multipart/form-data\">");
print ("<font face=\"MS Sans Serif\"><font color=\"#03CD00\"><b>File Name: </b></font>");
//print ("<INPUT TYPE=HIDDEN NAME=\"MAX_FILE_SIZE\" VALUE=\"25600\">");
print ("</font><INPUT TYPE=FILE NAME=\"File\" SIZE=60>\n<p>");
print ("<font face=\"MS Sans Serif\"><input type=\"submit\" value=\"Upload Now\" style=\"color: #03CD00; font-weight: bold\" >");
print ("<INPUT TYPE=\"button\" value=\"CLOSE THIS WINDOW\" onClick=\"window.close();return false\" style=\"color:#FF0000; font-weight: bold\"></font></FORM>\n");
?>😕