Hi,

I am trying to insert to insert a video into a folder and its path into the database.
But both the things are not working for me.
And also I need to retrieve the video from database.
Can someone help me where i went wrong.
My html to upload video is

<form action="" method="post" enctype="multipart/form-data">
<div class="form_search">
<label>Upload Video Profile:</label>
<span class="form_input">
<input type="file" name="uploadvideo"  />
</span>
</div>

<div class="form_search">
<label> &nbsp;</label>
<span class="form_input">
<input type="submit" name="submitdetails" value="Upload" class="button"/>
</span>
</div>
</form>

and my php code to store the video in a folder named "company_profile" is

<?php
if(isset($_POST['submitdetails']))
{
    $name=$_FILES['uploadvideo']['name'];
    $type=$_FILES['uploadvideo']['type'];
    //$size=$_FILES['uploadvideo']['size'];
    $cname=str_replace(" ","_",$name);
    $tmp_name=$_FILES['uploadvideo']['tmp_name'];
    $target_path="company_profile/";
    $target_path=$target_path.basename($cname);
    if(move_uploaded_file($_FILES['uploadvideo']['tmp_name'],$target_path))
    {
        echo "hi";
        echo "Your video ".$cname." has been successfully uploaded";
    }
}

?>

Please help me how i can store the video file and retrieve it

Your code seems ok.
You can try the following:

  • Open your php.ini file.
  • Make a backup of that file.
  • Find the term "post_max_size" > Change this value to something higher (than the file you are uploading)
  • Find the term "upload_max_filesize" > Change this value to something higher
  • Save the file and Restart your webservice.

Now try uploading your file again. Hope this works (at least I did this when it happened to me).

Thanks for ur reply , but my file is only 7mb of size.
is it required to modify php.ini
Anyway i am going to try that now.

Let me know if that helped, or we shall try something else.

Member Avatar for diafol

Have you considered hosting the video on a service like YouTube or Vimeo? General servers are pretty poor at delivering video, especially if you have a lot of visitors. You then just need to store the unique id in the DB and build the iframe code with that id - quite simple.

when i upload a video of format mp4 it shows me invalif file extension. what can i do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.