Jump to content

need help moving a file after a form submission


mwusaw

Recommended Posts

I am having trouble moving a file to a permanent directory. The select menu is dynamically generated from the files in a temp directory. Once someone selects that file and adds information through a form, I want that file to be moved to a different directory so it no longer appears in the list of available files.

 

This is the coding I am using, the details are added to the db, but the file isnt moving

 

<select name="video_file" Style="font-size:8pt">

<option></option>

<?

    $path = "/home/themat1/public_html/temp_files/";

 

    $dir_handle = @opendir($path) or die("Unable to open $path");

 

    while ($file = readdir($dir_handle)) {

 

    if($file == "." || $file == ".." || $file == "index2.php" )

 

        continue;

        echo "<option>$file</option>$file";

    }

?>

 

</select>

 

<input type="hidden" name="MM_insert" value="addvideo">

<center><input name="submit" type="submit" value="Submit" Style="font-size:8pt"></center>

</form>

<?php   

if(isset($_POST['submit'])){ 

rename('/home/themat1/public_html/temp_files/$file', '/home/themat1/public_html/video_files/$file');

}

?>

 

any suggestions?

 

Thanks

i changed the move code to...

 

<?php   

if(!$errorflag) {

rename('/home/themat1/public_html/temp_files/'.$_POST['video_file'].'', '/home/themat1/public_html/video_files/'.$_POST['video_file'].'');

}

?>

 

but now its moving every file from the temp directory and deleting the temp directory.  Anyone have any ideas how to get just the selected file to move?

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.