silverglade Posted June 9, 2010 Share Posted June 9, 2010 hi, this is the code i have so far, i want to put the video on its own page pulled from the database. echo '<a href="picture.php?fileName='.urlencode($picture['fileName']).' "><object data="data/test.mpg" type="video/mpeg" width="320" height="255"> <param name="src" value="data/test.mpg"> <param name="autoplay" value="false"> <param name="autoStart" value="0"> alt : <a href="data/test.mpg">test.mpg</a> </object> '; Link to comment https://forums.phpfreaks.com/topic/204271-need-to-use-php-to-output-info-for-a-video-to-show-on-its-own-page/ Share on other sites More sharing options...
trq Posted June 9, 2010 Share Posted June 9, 2010 What exactly is the question / problem? Link to comment https://forums.phpfreaks.com/topic/204271-need-to-use-php-to-output-info-for-a-video-to-show-on-its-own-page/#findComment-1069885 Share on other sites More sharing options...
silverglade Posted June 9, 2010 Author Share Posted June 9, 2010 i have a php page that lets you upload images into an uploads folder and the name is put into a database. then the get page gets the image and displays the larger version. i am altering it to have it upload videos , and i want the get page to display the video. but im having problems with the code. this is as far as i got. require_once('database1.php'); function checkFile($fileName) { if (!empty($_FILES) && !empty($_FILES[$fileName]) &&//why use files file. ($_FILES[$fileName]["type"] == "video/x-msvideo") //.avi || ($_FILES[$fileName]["type"] == "video/quicktime") //quicktime || ($_FILES[$fileName]["type"] == "video/x-ms-asf") || ($_FILES[$fileName]["type"] == "video/mp4") || ($_FILES[$fileName]["type"] == "audio/x-ms-wmv") || ($_FILES[$fileName]["type"] == "video/x-ms-wmv") || ($_FILES[$fileName]["type"] == "video/mpeg") && ($_FILES[$fileName]["size"] < 10000000)) {//400k file size max that is from the "videos.php" upload page. and this is the get page <?php echo '<object data="upload/'.$_GET['fileName'].'" type="video/mpeg" width="320" height="255"> <param name="src" value="upload/'.$_GET['fileName'].'"> <param name="autoplay" value="false"> <param name="autoStart" value="0"> </object> '; ?> Link to comment https://forums.phpfreaks.com/topic/204271-need-to-use-php-to-output-info-for-a-video-to-show-on-its-own-page/#findComment-1069887 Share on other sites More sharing options...
silverglade Posted June 9, 2010 Author Share Posted June 9, 2010 here is the full code to the video upload page. <?php require_once('database1.php'); function checkFile($fileName) { if (!empty($_FILES) && !empty($_FILES[$fileName]) &&//why use files file. ($_FILES[$fileName]["type"] == "video/x-msvideo") //.avi || ($_FILES[$fileName]["type"] == "video/quicktime") //quicktime || ($_FILES[$fileName]["type"] == "video/x-ms-asf") || ($_FILES[$fileName]["type"] == "video/mp4") || ($_FILES[$fileName]["type"] == "audio/x-ms-wmv") || ($_FILES[$fileName]["type"] == "video/x-ms-wmv") || ($_FILES[$fileName]["type"] == "video/mpeg") && ($_FILES[$fileName]["size"] < 10000000)) {//400k file size max //echo 'check1'; //FOR DEBUGGING CHECKS IN CERTAIN SPOTS //THIS HAS PHP AUTOMATIC ERRORS TO DISPLAY it will display the file name and the error////////////////////////////////////////////////////////////// if(!empty($_FILES[$fileName]["error"])) { //echo 'check4'; return "Error: " . $_FILES[$fileName]["error"] . "<br />";//puts out error if a file error exists. } elseif (file_exists("upload/" . $_FILES[$fileName]["name"])) { //echo 'check5'; return $_FILES[$fileName]["name"] . " already exists. "; //we can access different file names from the form using "name". } elseif(!move_uploaded_file($_FILES[$fileName]["tmp_name"], "upload/" . $_FILES[$fileName]["name"])) { //OTHERWISE UPLOAD THE FILES TO THE DIRECTORY /UPLOAD //echo'check2'; return 'Error uploading file.'; } else { return false; } } else { return 'Incorrect file size or type.';; } } function checkLength($variable, $variableString){ if(strlen($variable) < 5) { return $variableString.' was too short, please make it larger than 5 characters.'; } elseif(strlen($variable) > 50) { return $variableString.' was too long, please make it smaller than 50 characters.'; } }//end function //for debugging //echo '<pre>' . print_r($_POST, 1) . '</pre>'; //echoes contents of POST array. if (isset($_POST['submitButton'])) { if (empty($_POST['pictureTitle'])){ $error['pictureTitle'] = 'Please enter a title for your picture'.' <br />'; //THE BELOW IS TO BE ECHOED OUT LATER. checks the length of picture title and puts <br /> //results into errror array that we can echo later . } elseif(checkLength($_POST['pictureTitle'], 'Picture title')) {//?????? $error['pictureTitle'] = checkLength($_POST['pictureTitle'], 'Picture title');//in checkLength, Picture title gets passed in as $variableString and then that is used to output relevant errors }//end elseif //start get file type code if(checkFile('file')) { //we get the 'file' from the form. $error['file'] = checkFile('file'); } elseif(checkFile('secondFile')) { $error['secondFile'] = checkFile('secondFile'); } else { //echo'check3';///////////////////////////////////////////////////////////////// ///////////////////FILES here is set when form is submitted. $checkSQL = 'SELECT pictureID FROM picture WHERE title = "'.$_FILES["file"]["name"].'"'; //we can access different file names from the form with ["name" $checkQuery = mysql_query($checkSQL); if (mysql_num_rows($checkQuery) > 0) { $error['file'] = 'error: file already exists.'; } else { $addSQL = ' INSERT INTO picture (title, fileName, timeCreated) VALUES ("'.mysql_real_escape_string($_POST['pictureTitle']).'", "'.mysql_real_escape_string($_FILES["file"]["name"]).'", "'.time().'")'; mysql_query($addSQL); //$_FILES['secondFile']['name']; we can access multiple file names with this if (mysql_error()) { $error['file'] = 'There was an error uploading to the database'; } else { $addSQL = ' INSERT INTO picture (title, fileName, timeCreated) VALUES ("'.mysql_real_escape_string($_POST['secondPictureTitle']).'", "'.mysql_real_escape_string($_FILES["secondFile"]["name"]).'", "'.time().'")'; mysql_query($addSQL); if(mysql_error()) { $error['secondFile'] = 'There was an error uploading the second file to the database.'; } else { $success = 'Files were successfully uploaded to the database!'; } } } } } else { $error['file'] = 'Error: file was not a gif, jpeg or pjpeg, or was over 400kb.'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="style.css" type="text/css"/> <title>Derek's gallery copy</title> <style type"text/css"> .style1 { font-size: larger; color: #FFFFFF } </style> </head> <!--YOU MUST BE USING EASYPHP LOCALHOST FOR THIS TO WORK, NOT THE "BROWSE" FUNCTION IN DW.--> <?php echo '<html><body>';?> <div id="container"> <?php include('includes/header.php');?> <?php echo "<p></p><div align='center'><h3>Welcome to the gallery, today's date is ". date("m/d/Y").". </h3></div><p></p>"; echo "<table align='center'><tr>"; $pictureSQL = 'SELECT fileName FROM picture'; $pictureQuery = mysql_query($pictureSQL); echo mysql_error(); $count = 0; echo '<tr>'; while($picture = mysql_fetch_assoc($pictureQuery)){ if($count%8 == 0) { //modulus, if $count is divisible by 8, start a new row. echo '</tr><tr>'; } echo '<td>'; echo '<a href="picture.php?fileName='.urlencode($picture['fileName']).' "><img src="upload/'.$picture['fileName'].'" "height="80" width="80" /></a>'; echo '</td>'; $count++; }//end while loop //echo '<pre>'.print_r($error,1).'</pre>';//debugs error array echo '</tr></table>'; ?> <form action="index_copy.php" method="post" enctype="multipart/form-data"> <br /> <table align="center" width="270" border="1"><tr> <td><span class="style1">Please upload your image</span> <br /> <br /> <?php if((isset($_POST['submitButton']))) { if (isset($error)) { echo 'The following errors ocurred.'; foreach ($error as $errorMessage) { echo $errorMessage. "<br />"; } } elseif (isset($success)){ echo $success; } }//end isset submit ?> <br /> <br /> <span class="style1">File Name</span> <input type="text" name="pictureTitle" id="pictureTitle" /> <input type="file" name="file" id="file"/> <span class="style1">File Name</span> <input type="text" name="secondPictureTitle" id="secondPictureTitle" /> <input type="file" name="secondFile"/> </td> </tr><tr> <td> <input type="submit" name="submitButton" value="submit" /></td> </tr> </table> </form> </div><!--end container--> </body> </html> Link to comment https://forums.phpfreaks.com/topic/204271-need-to-use-php-to-output-info-for-a-video-to-show-on-its-own-page/#findComment-1069888 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.