Jump to content

Recommended Posts

Hi all,

 

Im looking for advice and guidance to achieve the following results.

 

I am using PHPTube - http://kamleitner.com/code/phptube-youtube-api-f-video-upload-download/ (This enables me to upload the file to my server then upload that file automatically to youtube.)

 

I want to have a web page that allows the user to browse for a video file and click submit to upload this file to my server. I have managed to get this part working. I am looking to enhance this a little by displaying a progression bar or animation on the same page whilst the upload is taking place.

 

Currently once the Submit button has been clicked a seperate .php page is loaded which displays the following details:

 

<?php

if ($_FILES["file"]["size"] < 500000)
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
echo "<img src='load.gif'>";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
  
  
  //upload video to youtube

include_once ("phptube.php");

//$tube = new PHPTube ();
//$tube->download("yTF3jS16Sbc","demo.flv");

$tube = new PHPTube ($_POST["uName"],$_POST["uPass"]);
$id = $tube->upload ("upload/" . $_FILES["file"]["name"], $_POST["uTitle"], $_POST["uTags"], $_POST["uDescription"],10, "EN", $_POST["uPublic"]);


      }
    }
  }
  

else
  {
  echo "Invalid file";
  }

?>

 

Does anybody have any idea how i can upload the file to my server without loading up a separate page and display an upload animation whilst doing so?

 

thanks for help with this.

 

Dan

Link to comment
https://forums.phpfreaks.com/topic/85965-upload-file-to-server-question/
Share on other sites

To upload the file to the server without loading up a separate page and to display a upload animation you have to use ajax for this.

 

This link might be helpful for u http://php5.bluga.net/UploadProgressMeter/demo.php.

 

Roshan Bhattarai

http://roshanbh.com.np

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.