将图片上传到服务器

时间:2014-04-10 15:01:08

标签: php

我正在尝试从我的网站上传文件到服务器,但这个PHP代码在运行时报告了一些错误:

<?php
      $target_path1 = "uploads/";

     /* Add the original filename to our target path.
     Result is "uploads/filename.extension" */

     $target_path1 = $target_path1 . basename( $_FILES['uploaded_file']['name']);
     if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path1)) 
      {
      echo "The first file ".  basename( $_FILES['uploaded_file']['name'])."has been uploaded.";
     } else {
       echo "There was an error uploading the file, please try again!";
       echo "filename: " .  basename( $_FILES['uploaded_file']['name']);
       echo "target_path: " .$target_path1;
    }
    ?>

我得到的错误是

Notice: Undefined index: uploaded_file in D:\anddev\project\web\upload_test\upload_media_test.php on line 5

Notice: Undefined index: uploaded_file in D:\anddev\project\web\upload_test\upload_media_test.php on line 6

Notice: Undefined index: uploaded_file in D:\anddev\project\web\upload_test\upload_media_test.php on line 11

我该如何解决这个问题?

0 个答案:

没有答案