0

I'm Trying this code to upload video.

but the code below is not working for me, can someone help?

Plese correct the code if required. I dont know php well..

<?php
mysql_connect("localhost","root","123456789");
mysql_select_db("vid");

if(isset($_POST['submit']))
{
        $name = $_FILES['file']['name'];
        $name = $_FILES['file']['temp_name'];

        move_uploaded_file($temp,"uploaded/".$name);
        $url = "http://localhost/video/uploaded/$name";
        mysql_query("INSERT INTO `videos` VALUE ('','$name','$url') ");
}

?>





<body>
<a href="videos.php">Videos</a>
<form action="upload.php" method="POST" enctype="multipart/form-data">

<input type="file" name="file" />
<br><br>
<input type="submit" name="submit" value="Upload" />
</form>
<?php
if(isset($_POST['submit']))
{
        echo "<br/>".$name." has been Uploaded";
}

?>


</body>

Thanks

  • `$name = $_FILES['file']['temp_name'];` should probably be `$temp = $_FILES['file']['temp_name'];` don't you think? – Sean May 06 '18 at 16:05
  • Hi Akash - please read https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php as well, as your code is currently vulnerable to SQL injection. – Erty Seidohl May 06 '18 at 16:12

0 Answers0