動画ファイルをサーバーにアップロードしようとしています。以下は videoadmininsert.php です。このファイルはユーザーに表示されるファイルで、videosave.php はファイルの検証が行われる場所であり、ファイルをフォルダーに保存します。サーバーで。問題は、ビデオ ファイルを選択するときです。たとえば、アップロードしようとしているファイルが 25 MB で、形式が wmv の場合、サーバーは、選択したファイルが正しいファイル拡張子ではないと言います。videoadmin.php
<?php
session_start();
$host="localhost"; // Host name
$username="ccili_userccili"; // Mysql username
$password="xxxxxxxxxxxxxxxx"; // Mysql password
$db_7name="ccili_BD"; // Database name
$tbl_name="Video"; // Table name
// Connect to server and select databse.
$con= mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
mysql_query("SET NAMES 'utf8'");
$_SESSION['whattodo']="insert";
?>
<!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 id="Head1" runat="server">
<title>Camara do comercio e industria Portugal - Iraque</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="StyleSheet.css" />
</head>
<body onload="display_ct(),display_ct2();">
<div id="wrap">
<div id="header">
<div id="Div1">
<div class="row dropdown-container fixed">
<div class="col-220">
<a id="logo" title="Back to amin" href="login_sucess.php">
<img width="220" alt="logo" src="../Images/logo.jpg"/>
</a>
</div>
<div class="col-701 last">
<p> </p>
<p class="get-in-touch">
<img width="14" height="10" alt="" src="../Images/flagpt.jpg"/>
<strong>
<script type="text/javascript">
function display_c() {
var refresh = 1000; // Refresh rate in milli seconds
mytime = setTimeout('display_ct()', refresh)
}
function display_ct() {
var strcount
var x = new Date()
var horas = x.getHours();
var min = x.getMinutes();
var sec = x.getSeconds();
if (horas < 10) {
horas = "0" + horas;
}
if (min < 10) {
min = "0" + min;
}
if (sec < 10) {
sec = "0" + sec;
}
document.getElementById('ct').innerHTML = horas + ":" + min + ":" + sec + " ";
tt = display_c();
}
</script> <span id='ct' ></span>
</strong>
<img width="14" height="10" alt="" src="../Images/flagiraque.jpg"/>
<strong>
<script type="text/javascript">
function display_c2() {
var refresh = 1000; // Refresh rate in milli seconds
mytime2 = setTimeout('display_ct2()', refresh)
}
function display_ct2() {
var strcount
var x = new Date()
var horas1 = x.getHours() + 2;
var min1 = x.getMinutes();
var sec1 = x.getSeconds();
if (horas1 < 10) {
horas1 = "0" + horas1;
}
if (horas1 > 24) {
horas1 = "0" + (horas1 - 24);
}
if (min1 < 10) {
min1 = "0" + min1;
}
if (sec1 < 10) {
sec1 = "0" + sec1;
}
document.getElementById('ct2').innerHTML = horas1 + ":" + min1 + ":" + sec1 + " ";
tt1 = display_c2();
}
</script> <span id='ct2' ></span>
</strong>
</p>
<p class="text-right">غرفة التجارة و الصناعة البرتغالية العراقية</p>
<p class="text-right1">Câmara do Comércio e Indústria Portugal-Iraque</p>
<p class="text-right">ژووری بازرگانی عیراق پۆرتگال</p>
</div>
</div>
</div>
</div>
<div id="content">
<div class="hr">
<p class="text-rightLogout"><a href="logout.php">Log Out!!!</a></p>
</div>
<div class="row fixed">
<div class="col-220">
<ul id="news-box">
<FORM name="form1" method="post" action="checkbutton.php">
<p><b>Home</b>
<INPUT TYPE="submit" name ="Button1" ID="Button1" VALUE="Edit Home." style="width:200px; height:30px;">
<INPUT TYPE="submit" name ="Button2" ID="Button2" VALUE="Edit Culture PT" style="width:200px; height:30px;">
<INPUT TYPE="submit" name ="Button3" ID="Button3" VALUE="Edit Culture IRAK" style="width:200px; height:30px;">
<b>About Us</b>
<INPUT TYPE="submit" name="Button4" ID="Button4" VALUE="Edit Mensagem Presidente" style="width:200px; height:30px;">
<INPUT TYPE="submit" name ="Button5" ID="Button5" VALUE="Edit Administration Board" style="width:200px; height:30px;">
<INPUT TYPE="submit" name ="Button6" ID="Button6" VALUE="Edit Consultive Board" style="width:200px; height:30px;">
<INPUT TYPE="submit" name ="Button7" ID="Button7" VALUE="Edit General Assembly" style="width:200px; height:30px;">
<INPUT TYPE="submit" name ="Button8" ID="Button8" VALUE="Edit Financial Council" style="width:200px; height:30px;">
<INPUT TYPE="submit" name ="Button9" ID="Button9" VALUE="Edit Founding Members" style="width:200px; height:30px;">
<b>Protocols</b>
<INPUT TYPE="submit" name="Button10"ID="Button10" VALUE="Edit Protocols" style="width:200px; height:30px;">
<b>Links</b>
<INPUT TYPE="submit" name="Button11" ID="Button11" VALUE="Edit Links" style="width:200px;height:30px;">
<b>Photos/News/Videos</b>
<INPUT TYPE="submit" name="Button12"ID="Button12" VALUE="Edit News" style="width:200px; height:30px;">
<INPUT TYPE="submit" name="Button13"ID="Button13" VALUE="Edit Photos" style="width:200px;height:30px;">
<INPUT TYPE="submit" name="Button14"ID="Button14" VALUE="Edit Videos" style="width:200px;height:30px;">
<b>Associates</b>
<INPUT TYPE="submit" name="Button15"ID="Button15" VALUE="Edit How To Join" style="width:200px;height:30px;">
<INPUT TYPE="submit" name="Button16"ID="Button16" VALUE="Edit List of Members" style="width:200px;height:30px;">
<INPUT TYPE="submit" name="Button17"ID="Button17" VALUE="Edit Associates Prime" style="width:200px;height:30px;">
<b>Contacts</b>
<INPUT TYPE="submit" name="Button18"ID="Button18" VALUE="Edit Adress" style="width:200px;height:30px;">
</FORM>
</p>
</ul>
</div>
<div class="col-460">
<?php
echo "<center><h1>Videos</h1></Center>";
echo "<center><h1>Insert</h1></Center>";
?>
<form action="VideosAdminSave.php" method="post"
enctype="multipart/form-data">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Insert Video</strong></td>
</tr>
<tr>
<td width="78">Title</td>
<td width="6">:</td>
<td width="294"><input name="title" type="text" id="title"></td>
</tr>
<tr>
<td width="78">Text</td>
<td width="6">:</td>
<td width="294">
<?php
echo "<input type='textarea' name='text1' size='61'> </textarea>" ;
?>
</td>
</tr>
<tr>
<td>File</td>
<td><label for="file">Filename:</label></td>
<td><input type="file" name="file" id="file" /></td>
</tr>
<tr>
<td><input type="submit" name="submitVideos" value="Submit" /></td>
</tr>
<input name="MAX_FILE_SIZE" value="40971520" type="hidden">
</table>
</td>
</form>
</div>
</div>
<div id="footer">
<div class="row fixed">
<div class="col-220">
<p >
<img width="130" height="70" alt="emb" src="Images/smartcom.jpg"/><br>
<strong>
© 2012
<a href="http://www.smartcom.pt">Smartcom,
<br/></a>Intelligent Communications
</strong>
</p>
<p >
All rights reserved.
<br/>
</p>
</div>
<div class="col-460 ">
</div>
</div>
</div>
</div>
</div>
</body>
</html>
そして、ここにvideosadminsaveがあります
<?php
session_start();
$host="localhost"; // Host name
$username="ccili_userccili"; // Mysql username
$password='xxxxxxxxxxxx'; // Mysql password
$db_name="ccili_BD"; // Database name
$tbl_name="Video"; // Table name
// Connect to server and select databse.
$con= mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
if(isset($_POST['Videos']))
{
$delete=$_POST['Videos'];
mysql_query("DELETE FROM Videos WHERE titulo='$delete' ");
echo "<script type='text/javascript'>
window.location = ('VideosAdmin.php');
</script>";
}
$title=$_POST['title'];
//echo $namept;
$texto=$_POST['text'];
$path="Videos/";
$allowedExts = array("avi", "mp4", "flv","mpeg","3ggp","wmv");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "video/mp4")
|| ($_FILES["file"]["type"] == "video/avi")
|| ($_FILES["file"]["type"] == "video/flv")
|| ($_FILES["file"]["type"] == "video/mpeg")
|| ($_FILES["file"]["type"] == "video/wmv")
|| ($_FILES["file"]["type"] == "video/3ggp"))
&& ($_FILES["file"]["size"] < 100000000000000000000000000000000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
//echo "<script type='text/javascript'>
//alert("Return Code: " . $_FILES["file"]["error"] . "<br />");
//</script>";
//echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
echo "<script type='text/javascript'> alert('Invalid File');window.location = ('VideosAdminInsert.php'); </script>";
}
else
{
//echo "Upload: " . $_FILES["file"]["name"] . "<br />";
//echo "Type: " . $_FILES["file"]["type"] . "<br />";
//echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
//echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists($path . $_FILES["file"]["name"]))
{
//echo $_FILES["file"]["name"] . " already exists. ";
//header("Location: editmsghome.php");
echo "<script type='text/javascript'> alert('The file already exist, please change the file name.');window.location = ('VideosAdminInsert.php');
</script>";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
$path . $_FILES["file"]["name"]);
//header("Location: editmsghome.php");
//guardar na base de dados....
error_reporting(E_ALL);
ini_set('display_errors',1);
//ob_start();
//session_start();
if(isset($_FILES["file"]["name"]))
{
$video=$_FILES["file"]["name"];
}
else
{
$video="";
}
mysql_query("INSERT INTO Video ( titulo,ficheiro) VALUES ('$title','$video')");
mysql_close($con);
//session_destroy();
echo "<script type='text/javascript'>
alert('The video was stored in the server ');
window.location = ('VideosAdmin.php');
</script>";
//fim de guardar na base de dados...
}
}
}
else
{
echo "<script type='text/javascript'> alert('Didnt choose the correct file... ');window.location = ('VideosAdmin.php'); </script>";
}
?>