我有一个数据表,其中包含图片和视频,文件保存在我的localhost的Eventpic文件夹中,我需要表格中的图片和视频,以便在用户点击时显示该文件;此代码指的是eventpic而不是每个单独的图片。
$sqlget="SELECT * FROM eventform";
$sqldata=mysqli_query($con,$sqlget)
or die("Error Getting Data");
echo "<table border=2 bordercolor=#440000 cellpadding=2 bgcolor=#DDDDDD width=100%>";
echo "<tr bgcolor=#555555 style=font-size:18px><th>Event Code</th><th>Event Name</th><th>Event Type</th><th>Event Level</th><th>Start Date</th>
<th>End Date</th><th>Point</th><th>Picture</th><th>Video</th><th>Description</th></tr>";
while($row=mysqli_fetch_array($sqldata, MYSQLI_ASSOC)){
echo "<tr align=center><td>";
echo $row['event_code'];
echo "</td><td>";
echo $row['event_name'];
echo "</td><td>";
echo $row['event_type'];
echo "</td><td>";
echo $row['event_level'];
echo "</td><td>";
echo $row['start_date'];
echo "</td><td>";
echo $row['end_date'];
echo "</td><td>";
echo $row['points'];
echo "</td><td>";
echo "<a href=http://localhost/greenstudio/eventpic/>".$row['pic']."</a>"; >>> PRoblem is here
echo "</td><td>";
echo $row['video'];
echo "</td><td>";
echo $row['description'];
echo "</td></tr>";
}
echo "</table>";
?>
======我的桌子=====
$pic= ($_FILES['pic']);
$temp_pic=($_FILES["pic"]["tmp_name"]);
$pic_type=($_FILES["pic"]["type"]);
$pic_name=($_FILES["pic"]["name"]);
$pic_size=($_FILES["pic"]["size"]);
$pic_error=($_FILES["pic"]["error"]);
$temp_video=($_FILES["video"]["tmp_name"]);
$video_type=($_FILES["video"]["type"]);
$video_name=($_FILES["video"]["name"]);
$video_size=($_FILES["video"]["size"]);
$video_error=($_FILES["video"]["error"]);
$uploads_dir_pic = "eventpic/".$pic_name;
$uploads_dir_video="videos/".$video_name;
if($pic_size>1000000){
die ("The size of the pic is too big");
}
if($video_size>5000000){
die ("The size of the video is too big");
}
move_uploaded_file($temp_pic,$uploads_dir_pic);
$path_pic=($uploads_dir_pic);
}
move_uploaded_file($temp_video,$uploads_dir_video);
$path_video=($uploads_dir_video);
INSERT $path_pic & $path-video in database
答案 0 :(得分:0)
你能试试吗,
echo "<a href='http://localhost/greenstudio/eventpic/".$row['pic']."' >".$row['pic']."</a>";
OR
echo "<a href='eventpic/".$row['pic']."' >".$row['pic']."</a>";
答案 1 :(得分:0)
创建一个单独的脚本,从数据库加载图像
设置图像的标题
header("Content-type: image/png");
这是类似的How to retrieve images from MySQL database and display in an html tag