Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

How to have a user specify file to be opened?

  • 19-10-2007 4:36am
    #1
    Registered Users, Registered Users 2 Posts: 32,605 ✭✭✭✭


    Hey lads, I have a query for yee!

    Im building, and nearly finished a website that will allow users to upload videos and attach them to other videos.

    Im a bit new to this so muddling my through it so far.
    One of the important features is that a user will upload an mpeg and a text file of the same name describing what their movie is about.
    Obviously before joining movies, one would like to view the parts, and read the description, so i Embedded a media player on the page which will play whatever path is in it, say;
    C:\Program Files\ApacheSoftwareFoundation\Apache2.2\htdocs\pcsvids\movie.mpg

    this path is in the code for the media player and thus inaccessible to change for the average user coming in. What I want is for the user to just be able to type the name of the file they want to view into a text box like "movie3.mpg"
    and that when they click a button, it would attach this movie name to the path
    C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pcsvids\
    so it would play that clip.

    For the description im doing the same thing. im using PHP fopen() and fread() so that the contents of a specified text file are presented on the page. Same deal here, want the user to be able to type the "name.txt" into a textbox and have that name attached to the prefix in the code.

    Any help or suggestions anyone could offer would be fantastic!

    Thanks
    -Paul

    P.S
    Was thinking of something like this, but, well, working..
    <form name="moviechoice">
      <input type="text" name="clip" value="Enter Movie Clip name" />
    </form>
    
     <button onclick="playMovie()">Play Movie</button>
      <p>&nbsp;</p>
        <script language="javascript" type="text/javascript">
    
      function playMovie(){
      <object id="MediaPlayer" width=303 height=248 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"> 
    
    <param name="filename" value="http://yourdomain/yourmovie.wmv">
    <param name="Showcontrols" value="True">
    <param name="autoStart" value="True">
    
    <embed type="application/x-mplayer2" src="C:\Program Files\ApacheSoftwareFoundation\Apache2.2\htdocs\pcsvids\[B](document.moviechoice.clip.value)[/B].mpg" name="MediaPlayer" width=303 height=248></embed>
    
    </object>
    
    }
    


Comments

  • Registered Users, Registered Users 2 Posts: 32,605 ✭✭✭✭~Rebel~


    im getting the impression this might be harder then i thought?


  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    ~Rebel~ wrote: »
    Im building, and nearly finished a website that will allow users to upload videos and attach them to other videos.

    So you want to join videos together? How do you plan on doing this?
    ~Rebel~ wrote: »
    One of the important features is that a user will upload an mpeg and a text file of the same name describing what their movie is about.

    OK, no problem.
    ~Rebel~ wrote: »
    Obviously before joining movies, one would like to view the parts, and read the description, so i Embedded a media player on the page which will play whatever path is in it, say;
    C:\Program Files\ApacheSoftwareFoundation\Apache2.2\htdocs\pcsvids\movie.mpg

    this path is in the code for the media player and thus inaccessible to change for the average user coming in. What I want is for the user to just be able to type the name of the file they want to view into a text box like "movie3.mpg"
    and that when they click a button, it would attach this movie name to the path
    C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pcsvids\
    so it would play that clip.

    Why don't you just dynamically create the links of what videos are available, and allow the user click on the link to view each part?

    For example -

    MAIN VIDEO HERE __Link to related video 1
    MAIN VIDEO HERE __Link to related video 2
    MAIN VIDEO HERE __Link to related video 3
    MAIN VIDEO HERE __Link to related video 4

    It's safer to limit user input and instead provide the options for him.
    ~Rebel~ wrote: »
    For the description im doing the same thing. im using PHP fopen() and fread() so that the contents of a specified text file are presented on the page.

    OK.
    ~Rebel~ wrote: »
    Same deal here, want the user to be able to type the "name.txt" into a textbox and have that name attached to the prefix in the code.

    I don't really understand this bit.


  • Registered Users, Registered Users 2 Posts: 32,605 ✭✭✭✭~Rebel~


    dublindude wrote:
    So you want to join videos together? How do you plan on doing this?
    Using a command line program called mpgtx that works on serversde. works well, though your limited to mpeg1. Its supposed to work with mpeg2, but so far hasn't for me.

    Why don't you just dynamically create the links of what videos are available, and allow the user click on the link to view each part?

    For example -

    MAIN VIDEO HERE __Link to related video 1
    MAIN VIDEO HERE __Link to related video 2
    MAIN VIDEO HERE __Link to related video 3
    MAIN VIDEO HERE __Link to related video 4

    It's safer to limit user input and instead provide the options for him.
    Ideally i would prefer if they just had to click, however the way i've done it is that using this php;
    <?php
    	#for windows
    	$dirname = "pcsvids";
    	$dir = opendir( $dirname );
    	while( false != ($file = readdir( $dir)))
    	{
    		if( ( $file !=  "." ) and ( $file != ".."))
    		{
    			$file_list .= "<li>$file</li>";
    		}
    	}
    	closedir( $dir );	
    ?>
    
    the files in the directory pcsvids show up on my page. They're not clickable though, just shows the names of the files. I did it this way as this is where the upload form will put the uploaded videos, so when they add videos and refresh the new ones will show up here. I went for trying to allow the user to type in the preview vid name so they could view vids i haven't made links for. Is there a way that the new vids added to that folder can appear as clickable links to play in the media player? Im totally new to PHP so just muddling my way through with methods im finding all over the place.
    [/quote]

    I don't really understand this bit.


    The vids and descriptive textfiles both appear listed on the page using the php i showed at the start of this post.
    This code;
     <?php
    	$filename = "pcsvids\\textfile1.txt";
    	$file = fopen(  $filename, "r" );
    	$filesize = filesize( $filename );
    	$text = fread( $file, $filesize );
    	fclose( $file );
    ?>
    	Text from <?php echo( "$filename"); 
    	echo( "<pre>$text</pre>" );
    ?>
    
    in this case will print the text from textfile1.txt onto the page so the viewer can read it. again this needs to be able to show text files i havent added yet so would be ideal if the user could just specify what will appear in the "textfile.txt" space.

    I would much rather the end user didn't have to do anything other then click, but im having trouble allowing them access things that will be added after im done.


  • Registered Users, Registered Users 2 Posts: 32,605 ✭✭✭✭~Rebel~


    Ok, I solved this part of the problem anyway;
    ~Rebel~ wrote:
    For the description im doing the same thing. im using PHP fopen() and fread() so that the contents of a specified text file are presented on the page. Same deal here, want the user to be able to type the "name.txt" into a textbox and have that name attached to the prefix in the code.

    with this bit of code;
    <form action="textviewer.php" method="post">
    Name:<input name="textfile"type="text"/>
    <input type="submit"/>
    </form>
    
     <?php
    	$filename = $_POST['textfile'];
    	$file = fopen(  $filename, "r" );
    	$filesize = filesize( $filename );
    	$text = fread( $file, $filesize );
    	fclose( $file );
    ?>
    	Text from <?php echo( "$filename"); 
    	echo( "<pre>$text</pre>" );
    ?>
    

    Still none the wiser on the media player problem though. Tried this;
    <form action="directthis.php" method="post">
    Name:<input name="videofile"type="text"/>
    <input type="submit"/>
    </form>
    
      <h3></h3>
      <object id="MediaPlayer" width=303 height=248 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"> 
    
    <param name="filename" value="http://yourdomain/yourmovie.wmv">
    <param name="Showcontrols" value="True">
    <param name="autoStart" value="True">
    
    <embed type="application/x-mplayer2" src="[B]<?php $_POST['videofile'];?>[/B]" name="MediaPlayer" width=303 height=248></embed>
    
    </object>
    

    but no luck


Advertisement