Jump to content

bflodesigner

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by bflodesigner

  1. Thank you PFMaBiSmAd! I think I understand what you mean - I have to make sure the upload was successful before I can check the file type and size. I'm very new to php so could you take it a step further and tell me exactly how to do it? Is it just a matter of switching the order in which it checks the file? And when you say to check the size and type separately, do you mean with another php file or just in this one, but with different checks to return different error messages? Thanks! Any help is greatly appreciated!
  2. When I'm testing this code I keep coming up with an error - Invalid File. I have restrictions on file types and size but id doesn't matter what size or type, keeps giving the error. Any suggestions? Thanks! Here's the code I am working with: <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/pdf") || ($_FILES["file"]["type"] == "image/tif")) && ($_FILES["file"]["size"] < 100000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1000000) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; //if (file_exists("upload/" . $_FILES["file"]["name"])) { if (file_exists("UPLOADED_FILES/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { //move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); move_uploaded_file($_FILES["file"]["tmp_name"], "UPLOADED_FILES/" . $_FILES["file"]["name"]); echo "Stored in: " . "UPLOADED_FILES/" . $_FILES["file"]["name"]; //copy-pasta some sendmail code from the contact form below this comment $toAddress = "emailaddress@gmail.com"; //sends email to this address $subject = "Files have been uploaded to FTP site"; //email subject //now send confirmation to the user $userContent = "Files have been uploaded to FTP site.\n\n" $headers = 'From: '.$toAddress."\r\n".'Reply-To: '.$toAddress; mail($toAddress, $subject, $userContent, $headers); } } } else { echo "Invalid file"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.