How can i upload a video and a picture at the same time to a server using php and my sql

Jeff

{ currently, all the samples I have seen so far are mainly for a single file upload. thank you in advance. i'm a student and this is my first task. I would equally love to download or save the files from data base back to my computer. I wrote the code in php and sql, my problem is that each time i try uploading the files to xampp free database,I keep on receiving one file instead of two files in my folder I really need a professional way to do it and avoid users from submitting the same file twice. Thanks.

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="post.php" method="POST" enctype="multipart/form-data">
    <input type="file" class="videofile" name="videofile">
    <input type="file" class="picturefile" name="picturefile">
    <input type="submit" class="submit" name="submit">
    </form>
</body>
</html>


    MYSQL
    
    CREATE TABLE userstable(id int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     VARCHAR (200) NOT NULL,
    videofile VARCHAR (200) NOT NULL,
    picturefile VARCHAR (200) NOT NULL,
    
    <?php
    
    include "connect.php";
    
    if(isset($_POST['submit'])){
    $videofile = $_FILES['vfile']['name'];
    $picturefile = $_FILES['pfile']['name'];
    
    $folder = "uploads/";
    
    
    if ($videofile == "" || $picturefile == ""){
        echo "Sorry, your file was not uploaded, ensure all filed are filed.";
    }
    
    else{
        move_uploaded_file($folder.$videofile, folder.$picturefile);
    
     
    
    
    mysqli_query ($user, "INSERT INTO usertable(videofile, picturefile) VALUES('$videofile', '$picturefile')");
    
        echo "Registration successful!";
    }
    }
    ?> }
kmoser

You need to call move_uploaded_file() twice: once for the video file and once for the picture file.

move_uploaded_file($_FILES['vfile']['tmp_name'], folder.$videofile);
move_uploaded_file($_FILES['pfile']['tmp_name'], folder.$picturefile);

The first argument is the name of the file on the server and the second argument is the name of the destination file.

You should also check the return value; see the move_uploaded_file() documentation.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I flip my card and at the same time I can click the picture to produce sounds?

how can i upload image using react native expo image to my local server PHP / Database MySQL

Upload video or picture with php

How can i update multiple databases at the same time in SQL Server?

How do I upload a picture to my blog using the Django administration

How i can connect my server to the tally using PHP

How can I upload a video to Firebase using angularfire2?

How can I play a youtube video AND ncmpcpp at the same time?

I can log into my sql server using php myadmin, but cant login using php

How can I change my default database in SQL Server without using MS SQL Server Management Studio?

How can I upload user's profile picture to server when registering new user ?

How can I make my SQL Server query efficient enough to not time out?

How can I stream multiple files at the same time using HTTP::Server?

How can I go to specific time in video using opencv?

How can I show a picture in design time in MFC picture control?

How do I make my c# Discord Bot notify my server when I upload a YouTube video to my channel

How can I implement video chat in my website using Django?

How can I upload a file to server, without browser, using go?

How can i upload a docx file on server using express js?

How can I upload a file in an FTP server using javascript?

How can I add my picture to my public key using GnuPG?

how to upload both image and video at the same time with laravel

In python how can I get the date and time of my local server?

How do I create my own server I can upload things to (like google drive) with Ubuntu server

How can I get my camera video RGB and other values in real time to my Python script / edit

How can I connect my Flutter app to local sql server database using API?

How can I get the IIS upload limit using PHP?

How can I do two foreach loops in php at the same time

How can I excute two cookies in same time with php