Jump to content

yonidebest

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About yonidebest

  • Rank
    Newbie
  1. yonidebest

    PHP file upload

    I have the following script based on the example script on http://www.w3schools.com/php/php_file_upload.asp . I get the following error now that I my host upgraded the server to PHP 5.5.The error:Strict Standards: Only variables should be passed by reference in /public_html/uploads/upload_file.php on line 7The code: $allowedExts = array("jpg", "jpeg", "pjpeg"); $extension = end(explode(".", $_FILES["file"]["name"])); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 3000000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else { $filename = (rand() * rand()); while (file_exists("images/" . $filename . ".jpg")) $filename = rand() * rand(); move_uploaded_file($_FILES["file"]["tmp_name"], "images/" . $filename . ".jpg"); /* write desc */ $myFile = $filename . ".txt"; $fh = fopen("images/" . $myFile, 'w') or die("can't open file"); fwrite($fh, "age: " . $_POST['age'] . "rn"); fwrite($fh, "religion: " . $_POST['religion'] . "rn"); fwrite($fh, "country: " . $_POST['country'] . "rn"); fwrite($fh, "desc: " . $_POST['desc'] . "rn"); fwrite($fh, "usage: " . $_POST['usage'] . "rn"); fwrite($fh, "time/date: " . date("Y-m-d H:i:s") . "rn"); fclose($fh); } } else { echo "um, eror"; } Can anyone tell my why I get this error and how to fix it? Thanks, Yoni
×
×
  • Create New...