Skip to content

Instantly share code, notes, and snippets.

@ninetwentyfour
Created August 28, 2011 19:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninetwentyfour/1177059 to your computer and use it in GitHub Desktop.
Save ninetwentyfour/1177059 to your computer and use it in GitHub Desktop.
Upload Videos To MediaSilo With PHP/FTP - blogpost
<?php
//MediaSilo Information
$server = "upload.mediasilo.com";
$ftp_user_name = "YOUR MEDIASILO LOGIN NAME AND HOSTNAME(e.g NAMEHOSTNAME";
$ftp_user_pass = "YOUR MEDIASILO LOGIN PASSWORD";
$dest = "THE WORKSPACE YOU WANT TO UPLOAD TO";
//Video Folder Information
$source_folder = "FULL PATH TO FOLDER. NO TRAILING SLASH (e.g. /var/www/videofolder)";
//Grabs everything in the source folder. You may want to set a file type like, ($source_folder."/*.flv")
$sources = glob($source_folder."/*.*");
//Connect to FTP
set_time_limit(0);
$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
//Check connection
if (!$connection || !$login) {
die('Connection attempt failed!');
}
//If there are no files, don't FTP to MediaSilo
if (empty($sources)) {
//Close the FTP connection
ftp_close($connection);
$fileUploadMessage = "No files selected for upload";
echo $fileUploadMessage;
}else{
//If there are files FTP them to MediaSilo
foreach ($sources as $source){
//Put each video file on FTP server
$upload = ftp_put($connection, $dest."/".basename($source) , $source, FTP_BINARY);
//Check upload status
//Display message
if (!$upload) {
echo "Cannot upload: ".basename($source)." <br />";
}else{
echo "Upload complete: ".basename($source)." <br />";
}
}
//Close the FTP connection
ftp_close($connection);
//Videos should now be uploaded to MediaSilo
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment