I want to upload file to my dreamhost server from other URL location is that possible?. There are many upload sample which upload files from clients local machine but i want to upload from different location can i do that? any help?
$source = 'http://source.com/file.xxx'; $target = 'path/to/folder/file.xxx'; echo @copy($source, $target) ? 'File saved' : 'Error receiving file'; PHP: This is probably the easiest way. (Not the safest though)
thax for help this is not working. I just want to save my bandwidth i want that dreamhost use their bandwidth to download files from URL location(internet not local files).
Error i am getting Note: I am successfully connect to my ftp account this code works fine $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); but it uses my bandwidth
doesn't dreamhost come with SSH access? just navigate to the directory you want to download the file to use 'cd directoryname' to go into a directory and 'cd ..' to come back to the upper level when you're in the directory you decided to download the file to type 'wget http :// www. domain. com/path/to/the/file' (with no spaces) and the server will download a copy of the file to the current directory you can use a client like putty (google for it) to access the server via SSH
I'm pretty sure, though not positive, that any script you make or use will take up your given bandwidth- the only things that do not are the control panel your host includes, and your root ftp. (Heh, correct me if I'm wrong though. . .) Basically anything over port 80 [HTTP] they will monitor and update your remaining bandwidth.
you'll need to use curl look at php.net/curl for documentation. If you cannot find it, i'll put some code sample here. But you need to specify the transfer, the connection type, headers, etc and you'll be easily able to transfer files.
Here's my actual code: function getcontents($filename) { if ($file = @file_get_contents($filename)) { } else { $curl = curl_init($filename); curl_setopt($curl, CURLOPT_HEADER, 0); // ignore any headers ob_start(); // use output buffering so the contents don't get sent directly to the browser curl_exec($curl); // get the file curl_close($curl); $file = ob_get_contents(); // save the contents of the file into $file ob_end_clean(); // turn output buffering back off } return $file; } Code (markup):
thx paradoxist1 for the info i can't use Control panel to upload files bcuz i want to upload about 50k files so need to write some code where i can run loops to finish this job