Jump to content

[SOLVED] 'cp' command in php?


tbare

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/83731-solved-cp-command-in-php/
Share on other sites

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?

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.";
}
?>

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.