我正在完成一个简单的视频文件上传。但我现在也要将图像上传到同一个文件夹。可能吗??
这是我的代码:
newvideo.html
<!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>Untitled Document</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload_file.php" method="POST">
Video Name :<input type="text" name="vname"/><br />
Category : <input type="text" name="cat"/><br />
Keywords : <input type="text" name="kwd"/><br />
Please choose a file: <input name="uploaded" type="file" /><br />
Please choose a image:<input type="file" name="image"><br />
<input type="submit" value="Upload" />
</form>
</body>
</html>
upload_file.php
<?php
include "config.php";
$videoname = $_REQUEST["vname"];
$category = $_REQUEST["cat"];
$keyword = $_REQUEST["kwd"];
$target = "C:/xampp/htdocs/upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if ($_FILES["uploaded"]["error"] > 0)
{
echo "Apologies, an error has occurred.";
echo "Error Code: " . $_FILES["uploaded"]["error"];
}
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
?>
<?php
$path = str_replace("C:/xampp/htdocs","http://localhost",$target);
$query = "INSERT INTO videos(videoname, category, keywords, path)";
$query .= "VALUE ('$videoname', '$category', '$keyword', '$path')";
$result = mysql_query($query);
?>