文件上传出错

时间:2016-01-14 16:02:37

标签: php html mysql file-upload

我是PHP新手 我有一个html文件,我使用文件上传

我的所有代码都运行良好,但在文件上传中我遇到错误

  

注意:第62行的C:\ wamp \ www \ Website \ movie_upload_action.php中的未定义索引:ppl_file

这是我的HTML代码

<?php 
    include "connection.php";
    include "sql.php";  
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload Movies detail</title>

<link href="css/bootstrap.min.css" rel="stylesheet">
</head>

<body style="background-color:#036; color:#FFF; font-family:'Times New Roman', Times, serif">
<form name="movie_upload" action="movie_upload_action.php" method="post">
<div style=" color:#FFF; height:50px; text-align:center; font-size:28px; font-weight:bolder; line-height:50px; font-family:'Times New Roman', Times, serif ">
Upload Movies Details
</div>
<div>
<table style="background-color:#036; color:#FFF; font-family:'Times New Roman', Times, serif;font-size:18px; font-weight:bolder;">
        <tr>
            <td width="120" >Movie Name:</td>
            <td colspan="8"><input type="text" name="movie_name" id="movie_name" placeholder="Input Movie Name Here" size="130px" /></td>
        </tr>

        <tr>
            <td>Upload Image: </td>
            <td width="10"><!--<input type="file" name="uploadedimage" id="uploadedimage"/>-->
            <input name="ppl_file" type="file">
            </td>
            <td width="05">Category:</td>
            <td width="10">
                <select name="category" id="category">
                <option value="Hollywood">Hollywood</option>
                <option value="Bollywood">Bollywood</option>
                <option value="Pakistani">Pakistani</option>
                <option value="Telugu">Telugu</option>
                <option value="Tamil">Tamil</option>
                <option value="Punjabi">Punjabi</option>
                <option value="Malayalam">Malayalam</option>
                <option value="Hindi Dubbbed">Hindi Dubbbed</option>
                </select>
            </td>
            <td width="10">Geners:</td>
            <td width="24"><input type="text" name="geners" id="geners" placeholder="Action, Comedy, Crime" /></td>
            <td width="24">Print</td>
            <td width="10"><input type="text" name="print" id="print" placeholder="Dvdsrc, HD" /></td>
        </tr>
        <tr>
            <td>Release year </td>
            <td width="10"><input type="date" name="release_year" id="release_year"/></td>
            <td width="05">Release Date:</td>
            <td width="10"><input type="date" name="release_date" id="release_date"/></td>
            <td width="10">Release Status:</td>
            <td width="24">
                <select name="release_status" id="release_status">
                <option value="upcomming">Upcomming</option>
                <option value="trailer">Trailer</option>
                <option value="released">Released</option>
                </select></td>
            <td width="24">Country</td>
            <td width="10">
                <select name="country" id="country">
                <?php for ($i=0; $i<count($country); $i++) {?>
<?php // echo $i ?>
                <option value="<?php echo $country[$i];?>"><?php echo $country[$i];?></option>
<?php }?>
                                </select></td>
            </td>

        </tr>
       <tr>
        <td>
                Language:
        </td>
        <td>
        <select name="language" id="language">
        <?php for ($i=0; $i<count($language); $i++) {?>
<?php // echo $i ?>
                <option value="<?php echo $language[$i];?>"><?php echo $language[$i];?></option>
<?php }?>
                </select>
        </td>
        <td> Directors:</td>
            <td>
            <input type="text" name="director" id="director" placeholder="Enter Diretors Name"/>
            </td>
            <td> Writers:</td>
            <td>
            <input type="text" name="writer" id="writer" placeholder="Enter Writer Name"/>
            </td>
            <td>Box Office:</td>
            <td><input type="text" name="box_office" id="box_office"/></td>
       </tr>
       <tr>
        <td>Actors:</td>
        <td>
            <input type="text" name="actor" id="actor" placeholder="Enter Actor Name"/>
        </td>

        <td>Torent Link:</td>
        <td> <input type="text" name="torrent" id="torrent" placeholder="Enter Torrent Link"/>
        </td>       
       </tr>
</table>

</br>
Download Link:<input type="text" name="link" id="link" placeholder="Enter Download Link" size="180"/>

</br>
</br>
Mobile Download: <input type="text" name="mobile_link" id="mobile_link" placeholder="Enter Mobile Download Link" size="180"/>

</br>
</br>
Online link: <input type="text" name="online_link" id="online_link" placeholder="Enter Watch Online Link" size="180"/>

</br>
</br>
Desription:
</br>
</br>
<textarea name="description" id="description" cols="180"> </textarea>
</br>
</br>
Tags: <input type="text" name="tag" id="tag" placeholder="Enter Tags" size="180"/>

</br>
</br>
<input type="submit" name="submit" id="submit" value="Submit"/>
<p class="navbar-inverse">&nbsp;</p>
</div>


</form>
</body>
</html>

这是我的行动档案

<?php
include "connection.php";
if(isset($_POST['submit'])){ // Fetching variables of the form which travels in URL

$movie_name = $_POST['movie_name'];
$category = $_POST['category'];
$geners = $_POST['geners'];
$print = $_POST['print'];
$release_year = isset($_REQUEST['release_year']) ? $_REQUEST['release_year'] : "";
$release_year=date('Y-m-d',strtotime($release_year));
$release_date = isset($_REQUEST['release_date']) ? $_REQUEST['release_date'] : "";
$release_date=date('Y-m-d',strtotime($release_date));
$release_status = $_POST['release_status'];
$country = $_POST['country'];
$language = $_POST['language'];
$director = $_POST['director'];
$writer = $_POST['writer'];
$box_office = $_POST['box_office'];
$actor = $_POST['actor'];
$torrent = $_POST['torrent'];
$link = $_POST['link'];
$mobile_link = $_POST['mobile_link'];
$online_link = $_POST['online_link'];
$description = $_POST['description'];
$tag = $_POST['tag'];
$Filepath=  "";


    $path_ppl = "image/";
$ppl_file="image/".basename( $_FILES['ppl_file']['name']);
$path_ppl = $path_ppl. basename( $_FILES['ppl_file']['name']); 


if(move_uploaded_file($_FILES['ppl_file']['tmp_name'], $path_ppl)) {
    echo "The file ".  basename( $_FILES['ppl_file']['name']). 
    " has been uploaded";
    echo"<br>";
} else{
    $path_draft_press_release="";
    echo "PPL Not Uploaded";
    echo"<br>";
}


$query_upload="INSERT INTO movies_detail(movie_name, image, category, geners, print, release_year, release_date, country, language, diretor, writer, box_office, description, tags, release_status, torrent_link, download_link, mobile_link, online_link) VALUES ('$movie_name','$Filepath','$category','$geners','$print','$release_year','$release_date','$country','$language','$director','$writer','$box_office','$description','$tag','$release_status'
,'$torrent','$link','$mobile_link','$online_link')";



    mysqli_query($con,$query_upload) or die("error in $query_upload == ----> ".mysql_error()); 

    echo "Data Inserted Successfully"; 



}
?>

以下代码出错

 $path_ppl = "image/";
$ppl_file="image/".basename( $_FILES['ppl_file']['name']);
$path_ppl = $path_ppl. basename( $_FILES['ppl_file']['name']); 


if(move_uploaded_file($_FILES['ppl_file']['tmp_name'], $path_ppl)) {
    echo "The file ".  basename( $_FILES['ppl_file']['name']). 
    " has been uploaded";
    echo"<br>";
} else{
    $path_draft_press_release="";
    echo "PPL Not Uploaded";
    echo"<br>";
}

请帮帮我

0 个答案:

没有答案