Sunday, 25 August 2013

Strict standard error in PHP

Strict standard error in PHP

I've looked at similar posts here but couldn't crack a solution. I'm
getting the Strict Standards: Only variables should be passed by reference
error here on the strtolower($file['name']))), line. Tried hours now
looking for a solution but couldn't figure out how to correct. Can you
highlight where I've gone wrong?
<?php
require_once 'upload_config.php';
$mydirectory = myUploadDir();
$uploaded_file_counter=0;
$UploadLimit = $_POST['counter'];
for($i=0;$i<=$UploadLimit;$i++){
$file_tag='filename'.$i;
$filename=$_FILES[$file_tag]['name'];
if($filename!=null) {
$rand=time();
$str="$rand$filename";
// set folder name in here.
$filedir= myUploadDir();
//change the string format.
$string= $filedir.$str;
$patterns[0] = "/ /";
$patterns[1] = "/ /";
$patterns[1] = "/ /";
$replacements[1] = "_";
$dirname=strtolower(preg_replace($patterns, $replacements,
$string));
//end of changing string format
//checking the permitted file types
if($check_file_extentions) {
$allowedExtensions = allowedfiles();
foreach ($_FILES as $file) {
if ($file['tmp_name']
> '') {
if
(!in_array(end(explode(".",
strtolower($file['name']))),
/* THIS IS
WHERE THE
ISSUE COMES */
$allowedExtensions))
{
$fileUploadPermission=0;
}
else
{
$fileUploadPermission=1;
}
}
}
}
else{
$fileUploadPermission=1;
}
....code continues....

No comments:

Post a Comment