yonidebest Posted November 8, 2013 Share Posted November 8, 2013 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 Link to comment Share on other sites More sharing options...
Ingolme Posted November 8, 2013 Share Posted November 8, 2013 The function end() expects a variable, not a function call. $f = explode(".", $_FILES["file"]["name"]);$extension = end($f); Link to comment Share on other sites More sharing options...
thescientist Posted November 8, 2013 Share Posted November 8, 2013 http://www.w3schools.com/php/func_array_end.asp http://us3.php.net/end Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now