Note that there are some explanatory texts on larger screens.

plurals
  1. POStrict Standarts Error while image upload with PHP script
    primarykey
    data
    text
    <p>I try to write an image uploader with php. But it is giving an error when I try.</p> <p><em><strong>Error is:</em></strong> </p> <p><strong>Strict Standards: Only variables should be passed by reference in C:\xx\xx\xx\profile_image_upload_script.php on line 10</strong></p> <p><em><strong>Line 10 is:</em></strong> <code>$extension = end(explode(".", $file_name_encrypted));</code></p> <hr> <p><strong>image upload script</strong></p> <pre><code>&lt;?php $allowedExts = array("gif", "jpeg", "jpg", "png"); $file_name = $_FILES["file"]["name"]; echo "File name:".$file_name; $file_name_encrypted = $file_name."".md5(rand(1, 1000000)); $extension = end(explode(".", $file_name_encrypted)); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/x-png") || ($_FILES["file"]["type"] == "image/png")) &amp;&amp; ($_FILES["file"]["size"] &lt; 2097152) // 2 MB &amp;&amp; in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] &gt; 0) { echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br&gt;"; } else { echo "Upload: " . $file_name_encrypted . "&lt;br&gt;"; echo "Type: " . $_FILES["file"]["type"] . "&lt;br&gt;"; echo "Size: " . ($_FILES["file"]["size"] / 1024*1024) . " MB&lt;br&gt;"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br&gt;"; if (file_exists("upload/" . $file_name_encrypted)) { echo $file_name_encrypted . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $file_name_encrypted); echo "Stored in: " . "upload/" . $file_name_encrypted; } } } else { echo "Invalid file"; echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br&gt;"; } ?&gt; </code></pre> <p>Note:script is getting file name from html form, there is no problem</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload