Results 1 to 3 of 3

Thread: How to avoid uploading of videos dynamically upon “refreshing” the page in browser?

  1. #1
    Join Date
    Jun 2017
    Location
    Bengaluru, Karnataka, India
    Posts
    15
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Lightbulb How to avoid uploading of videos dynamically upon “refreshing” the page in browser?

    Here I can upload videos successfully into database and videos are saving in appropriate folder named "uploaded". As I mentioned in question, once after uploading the video, if I refresh the browser the previously uploaded video is going saving in my database. Another question is, I cannot see or watch the videos. I request you people to give me solutions to solve these problems. Below I am posting my code:

    myvideo.php:

    <div class="content">
    <div class="card">
    <div class="header" id="stand-fix" style="border-bottom: 1px solid #E1E1E1;">
    <?php
    if(isset($_POST['submit']))
    {
    // $conn = mysqli_connect("localhost", "root", "", "videos") or die(mysqli_error());
    $name = (isset($_FILES['file']['name']) ? $_FILES['file']['name'] : '');
    $temp = (isset($_FILES['file']['tmp_name']) ? $_FILES['file']['tmp_name'] : '');
    move_uploaded_file($temp, "uploaded/".$name);
    $url = "http://localhost/xampp/htdocs/VS/uploaded/$name";
    mysqli_query($database, "INSERT INTO video VALUE ('','$name','$url')");
    }
    ?>
    <form action="myvideo.php" method="post" enctype="multipart/form-data">
    <div class="row">
    <div class="col-md-7">
    <h4 class="title">My Videos</h4>
    </div>
    <div class="col-md-3">
    <input type="file" name="file" class="btn btn-primary" style="font-size: 15px;"><br />
    </div>
    <div class="col-md-2">
    <input type="submit" name="submit" class="btn btn-primary pull-right" style="font-size: 15px;" value="Upload">
    </div>
    </div>
    </form>
    <?php
    if(isset($_POST['submit']))
    {
    echo '<script language="javascript">';
    echo 'alert("Your video has been successfully uploaded.")';
    echo "window.location.href='dashboard.php'";
    echo '</script>';
    }
    ?>
    <hr width="50%">
    </div>
    <div class="content" style="height: 30em; direction: ltr; overflow: auto;">
    <div class="row" style="margin-left:4em;" style="direction: rtl;">
    <?php
    $database = mysqli_connect("localhost", "root", "", "videos") or die(mysqli_error());
    $query = mysqli_query($database, "SELECT * FROM video");
    while($row=mysqli_fetch_assoc($query))
    {
    $id = $row['id'];
    $name = $row['name'];
    $url = $row['url'];
    echo "<p style='margin:0.5em;'><a href='watch1.php?id=$id' style='color:red;'>$id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$name</a></p><br />";
    echo "<embed src='.$id.$url.'><video width='200' height='200' controls></video></embed>";
    }
    ?>
    </div>
    </div>
    </div>
    </div>

    watch.php

    <?php
    $conn = mysqli_connect("localhost", "root", "", "videos") or die(mysqli_error());
    if(isset($_GET['id']))
    {
    $id = $_GET['id'];
    $query = mysqli_query($conn, "SELECT * FROM video WHERE id='$id'");
    while($row=mysqli_fetch_assoc($query))
    {
    $name = $row['name'];
    $url = $row['url'];
    }
    echo "<p style='font-size:20px;'><center>You are watching ".$name."</center></p><br /><embed src='.$url.'><video width='600' height='400' controls></video></embed>";
    }
    else
    {
    echo "Error!";
    }
    ?>

  2. #2
    Join Date
    Jun 2017
    Location
    Bengaluru, Karnataka, India
    Posts
    15
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Hello Everybody, as I posted in my question, I have solved the bug of "addition of files upon refreshing the page" by simply "rendering the page/adding landing page". But I cannot watch/view my videos uploaded in my web page. Kindly give me a solution for this.

    Thank You,

  3. #3
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Try using the correct <video> element syntax https://www.html5rocks.com/en/tutorials/video/basics/
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  4. The Following User Says Thank You to Beverleyh For This Useful Post:

    ak47 (07-03-2017)

Similar Threads

  1. Replies: 0
    Last Post: 06-22-2017, 10:18 AM
  2. Replies: 3
    Last Post: 02-06-2015, 06:57 PM
  3. Replies: 0
    Last Post: 11-27-2006, 01:37 AM
  4. Replies: 3
    Last Post: 10-16-2006, 07:45 PM
  5. Howto avoid Page break inside <tr>
    By Vijayaraj in forum HTML
    Replies: 4
    Last Post: 08-10-2006, 02:02 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •