douhao9203 2014-04-19 05:40
浏览 59

严格的标准:只传递变量[重复]

This question already has an answer here:

I have image upload script which shows this (Strict standards: Only variables should be passed by reference in C:\wamp\www\Fcomail-Final\cpanel\fcomail\Gallery.php on line 33 Call Stack) error Line no 33 is

require('../conn/include.php');
require('quick.php');
$query="SELECT * FROM category";
$result=mysql_query($query);
$project=$_POST['project'];
$alttext=$_POST['alttext'];
$relation=$_POST['Section'];;

if(isset($_FILES['image'])) {
    $errors=array();
    $allowed_ext=array('jpg','png','jpeg','JPG');
    $filename=$_FILES['image']['name'];
    $name=stripslashes($filename);
    **Line 33** $type=strtolower(end(explode('.',$filename)));
    $size=$_FILES['image']['size'];
    $file_tmp=$_FILES['image']['tmp_name'];
if(in_array($type,$allowed_ext) ===false) {
    $errors[]= "<span class=\"notification n-error\">Extenstion Not Allowed</span>";
}if($size > 1048576) {
    $errors[]= "<span class=\"notification n-error\">File must be less then 2mb</span>";
}if(file_exists('../../images/fcomail/gallery/'.$filename)) {
   $errors[]= "<span class=\"notification n-error\">File $filname Already Exists in directory</span>";
}if(empty($errors)) {
    if(move_uploaded_file($file_tmp, '../../images/fcomail/gallery/'.$filename)) {
        $insert="Insert into `my`.gallery(name,alttext,project,relation)VALUES('$name','$alttext','$project','$relation')";
        //echo $insert;
        $que=mysql_query($insert);
    echo "<span class=\"notification n-success\">File $filname Uploaded Sucessfully</span>";
    }
}else {
    foreach($errors as $error) {
        echo $error,'<br/>';    
    }
}
}
</div>
  • 写回答

1条回答 默认 最新

  • dtnwm4807 2014-04-19 05:42
    关注

    You need to break the below line

    $type=strtolower(end(explode('.',$filename)));
    

    to

    $fname = explode('.',$filename);
    $filename = end($fname);
    $type=strtolower($filename);
    

    Reason :

    From the documentation of end() in PHP Manual.

    The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集