I have a code. But move_uploaded_file is not working.
This is my code below:
is there any way to upload all types of with one field like Image/Video?
<?php
if(isset($_POST['save_news']))
{
$file=$_FILES['image']['tmp_name'];
$image= addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name= addslashes($_FILES['image']['name']);
$location="news/" . $_FILES["image"]["name"];
$vfile=$_FILES['video']['tmp_name'];
$vid= addslashes(file_get_contents($_FILES['video']['tmp_name']));
$video_name= addslashes($_FILES['video']['name']);
$video ="news/" . $_FILES['video']['name'];
$q = mysql_query("INSERT INTO news(video,image) VALUES('$video',
'$location')");
if(!$q)
{
echo mysql_error();
}
else
{
move_uploaded_file($_FILES["video"]["tmp_name"],"../news/" . $_FILES["video"]["name"]);
move_uploaded_file($_FILES["image"]["tmp_name"],"../news/" . $_FILES["image"]["name"]);
$_SESSION['mass_added']= 'echo"you are logged in"';
echo "<script>window.location = 'manage_news.php?user_type=admin'</script>";
}
}
?>
You need to check the errors to find out why. Do this by looking at $_FILES['video']['error']
.
My guess would be that if you're uploading videos, their filesize is too large. You can change the maximum upload file size in php.ini with `upload_max_filesize=..." ( see here ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.