我想我创建了一个文件上传到数据库并从数据库系统显示。在此文件上传系统中,我可以上传图像。但是视频没有被上传。上传视频和图像该怎么办?
<?php
$msg="";
if(isset($_POST['submit'])){
$target = "images/".basename($_FILES['image']['name']);
$db = mysqli_connect('localhost','root', '', 'prac');
$topic=$_POST['topic'];
$text=$_POST['caption'];
$image=$_FILES['image']['name'];
$sql= "INSERT INTO post(topic, caption, image) VALUES ('$topic', '$text', '$image')";
mysqli_query($db, $sql);
if(move_uploaded_file($_FILES['image']['tmp_name'],$target)){
$msg="Image Uploaded";
}
else{
$msg="Problem uploading image";
}
}
?>
<?php echo $msg ?>
<div id="content">
<form method="POST" action="prac.php" enctype="multipart/form-data">
<input type="hidden" name="size" value="100000">
<select name="topic" required>
<option></option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<input type="text" name="caption" placeholder="caption">
<input type="file" name="image">
<button type="submit" name="submit">POST </button>
</form>
<?php
$db = mysqli_connect('localhost','root', '', 'prac');
$sql = "SELECT * FROM post";
$result= mysqli_query($db, $sql);
while ($row = mysqli_fetch_array($result)){
echo "<tr>"."<img src='images/".$row['image']."' height='300px' max-width='100%'>"."</tr>";
echo "<tr>"."<p>".$row['caption']."</p>"."</tr>";
}
?>
答案 0 :(得分:0)
将此代码用于带有验证的视频和图像上传。
using System;
using System.Text;
using System.Xml;
using Microsoft.Extensions.Logging;
public static void Run(string myIoTHubMessage, out object outputDocument,
ILogger log)
{
StringBuilder output = new StringBuilder();
if(myIoTHubMessage.Contains("Root"))
{
output.Append("<?xml version='1.0' encoding='UTF-8'?><text>" +
myIoTHubMessage + "</text>");
}
string returnstring = output.ToString();
if(returnstring.Contains("xml"))
{
XmlDocument returnXml = new XmlDocument();
returnXml.LoadXml(returnstring);
outputDocument = new
{
returnXml
};
}
else
{
outputDocument = new
{
myIoTHubMessage
};
}