2013-05-13 3 views
7

का उपयोग कर स्थानीय सर्वर पर कॉपी करें मान लें कि रिमोट सर्वर पर एक फ़ाइल है जिसे बिना किसी प्रतिबंध के डाउनलोड किया जा सकता है। आप अपने ब्राउज़र में फ़ाइल को सीधा लिंक डाल सकते हैं और यह फ़ाइल डाउनलोड करता है, उदाहरण के लिए http://www.remotesite.com/video.avi आपके ब्राउज़र को उस फ़ाइल को डाउनलोड करने के लिए संकेत देगा। PHP का उपयोग करके, उस फ़ाइल को पकड़ने का सबसे अच्छा तरीका क्या है और फ़ाइल को मेरे पीसी पर डाउनलोड किए बिना मेरे स्थानीय सर्वर पर अपलोड करना क्या है, यदि आप फ़ाइल अपलोड फॉर्म में यूआरएल डालते हैं तो phpbb के साथ क्या होता है? आवश्यक कोड का एक उदाहरण भी सराहना की जाएगी। धन्यवाददूरस्थ सर्वर से फ़ाइल प्राप्त करने का सर्वोत्तम तरीका और php

+0

http://php.net/manual/en/function.file- get-content.php –

उत्तर

23

बस का उपयोग copy

$source = "http://www.remotesite.com/video.avi"; 
$dest = "video.avi"; 
copy($source, $dest); 
+1

'file_get' और' file_put' से अच्छा लगता है :) –

+1

हैशटैग सादगी –

3
$remote_file_contents = file_get_contents('http://remote_url/file/with.extension'); 
//Get the contents 

$local_file_path = 'your/local/path/to/the/file/with.extension'; 

file_put_contents($local_file_path, $remote_file_contents); 
//save the contents of the remote file 
+0

http://www.php.net/manual/en/function.file-put-contents.php –

2

आप पढ़ सकते हैं और ब्राउज़र डाउनलोड के बिना फ़ाइल लिख सकते हैं

<?php 

$file = 'http://www.remotesite.com/video.avi'; 

// read the file from remote location 
$current = file_get_contents($file); 

// create new file name 
$name = "path/to/folder/newname.avi"; 

// Write the contents back to the file 
file_put_contents($file, $current); 
संबंधित मुद्दे