mwusaw Posted February 26, 2009 Share Posted February 26, 2009 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 Link to comment https://forums.phpfreaks.com/topic/147056-need-help-moving-a-file-after-a-form-submission/ Share on other sites More sharing options...
mwusaw Posted February 27, 2009 Author Share Posted February 27, 2009 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 Link to comment https://forums.phpfreaks.com/topic/147056-need-help-moving-a-file-after-a-form-submission/#findComment-772263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.