在个人资料中运行上传

时间:2014-09-10 04:21:01

标签: php oop file-upload upload

我能够编写这个代码:

<?php

      if(isset($_FILES['profile']) === true) {
          if (empty($_FILES['profile']['name']) === true) {
              echo 'Please choose a file!';
        } else {
               $allowed = array('jpg', 'jpeg', 'gif', 'png');

              $file_name = $_FILES['profile']['name']; //file   //line 75
              $file_extn = strtolower(end(explode('.' , $file_name))); //line 76
              $file_temp =  $_FILES['profile']['tmp_name']; // line 77


               if (in_array($file_extn, $allowed) === true) {
                //upload file

               } else {
                  echo 'incorrect file type. Allowed: ';
                   echo implode(' , ' , $allowed);


          }
        }

      }

      if (empty($user->data()->profile) === FALSE) {
      echo '<img src="', $user->data()->profile, '" alt= "', $user->data()->profile, '\'s Profle Image">';

      }
    ?>

然后突然出现错误:

严格的标准:在第76行的C:\ wamp \ www \ coding_exam \ index.php中只能通过引用传递变量

1 个答案:

答案 0 :(得分:0)

if (empty($user->data()->profile) === FALSE) {
   echo '<img src="', $user->data()->profile, '" alt= "', $user->data()->profile, '\'s Profle Image">';

您无法像这样使用$ user-&gt; data() - &gt;个人资料。这就是问题所在。