tbare Posted December 30, 2007 Share Posted December 30, 2007 basically what i'm wanting to do is: upload a file w/ an upload script, and upon upload, 'cp' (in linux) a file in another directory (as to create a new file in a directory that has the same information as the original) using the uploaded files name (file.ext) and adding the extension '.dat' (to make it 'file.ext.dat')... my question is, is there a cp or duplicate command in php? i've searched, but to no avail... ...and you people here are smart <-(shameless butt-kissing) TIA ~TBare Quote Link to comment https://forums.phpfreaks.com/topic/83731-solved-cp-command-in-php/ Share on other sites More sharing options...
Daniel0 Posted December 30, 2007 Share Posted December 30, 2007 copy() Quote Link to comment https://forums.phpfreaks.com/topic/83731-solved-cp-command-in-php/#findComment-426003 Share on other sites More sharing options...
tbare Posted December 30, 2007 Author Share Posted December 30, 2007 heh... thanks... i'm assuming in the context: copy("folder/original_file", "folder/new_file"); ? Quote Link to comment https://forums.phpfreaks.com/topic/83731-solved-cp-command-in-php/#findComment-426004 Share on other sites More sharing options...
hitman6003 Posted December 30, 2007 Share Posted December 30, 2007 If you are uploading the file, use the "'move_uploaded_file" command, rather than just "copy". There are some additional security checks performed. http://www.php.net/move_uploaded_file Quote Link to comment https://forums.phpfreaks.com/topic/83731-solved-cp-command-in-php/#findComment-426016 Share on other sites More sharing options...
tbare Posted December 30, 2007 Author Share Posted December 30, 2007 yeah... i know that... thanks though... basically, what i'm doing though, is uploading a video file and thumbnail image of the video file... i have a rating system set up that uses hard files (because i don't have sql available on my server (free hosting.. what can ya do?)). so i need to make a copy of 'default.dat' to 'uploaded_file.flv.dat' so i don't get errors thrown @ me... make sense? Quote Link to comment https://forums.phpfreaks.com/topic/83731-solved-cp-command-in-php/#findComment-426022 Share on other sites More sharing options...
tbare Posted December 30, 2007 Author Share Posted December 30, 2007 works great.. thanks code: <?php if (move_uploaded_file($_FILES['uploaded_video']['tmp_name'], $uploadfile) && move_uploaded_file($_FILES['uploaded_thumb']['tmp_name'], $uploadfile2)) { copy("../ratings/dat/video/default.dat", "../ratings/dat/video/".$category."/".basename($_FILES['uploaded_video']['name']).".dat"); chmod("../ratings/dat/video/".$category."/".basename($_FILES['uploaded_video']['name']).".dat", 0777); echo "$file_name and $file_name2 was successfully uploaded.<br><br>\n"; print "The path to the video file is \"files/video/".$category."/".$file_name."\"<br>\n"; print "The path to the thumbnail is \"files/video/".$category."/thumbs/".$file_name2."\"<br><br><br>\n"; print "<p><a href='../index.php'>take me home</a></p>"; } else{ print "ERROR: No files uploaded."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/83731-solved-cp-command-in-php/#findComment-426036 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.