אני עושה עכשיו משהו נורא בסיסי, מקווה שזה יסדר את הבעיה.
קובץ HTML
<html> <title></title> <head></head><body> <form action="remote.php" method="post" /> <input type="text" name="file_add" /> <input type="submit" value="download" /> </form> </body> </html>
|
קובץ PHP שנקרא
remote.php
<?php function cached_fopen($file, $file_mode, $timeout_seconds = 600, $cache_path = "/tmp"){ $debug=false; clearstatcache(); $break = explode('/', $_SERVER); $file = $break; $ext = substr(strrchr($file, '.'), 1); $cache_filename=$cache_path . "/" . urlencode($file) .".".$ext; if ($debug) { print "local_cache creation_time =" . @filemtime($cache_filename) . " actual time = " . time() . " timeout = " . $timeout_seconds ."<p>";} if ( ( @file_exists($cache_filename ) and ( ( @filemtime($cache_filename) + $timeout_seconds) > ( time() ) ) ) ){ // ok, file is already cached and young enough if ($debug) { print "using cached file ($cache_filename) <p>";} } else { if ($debug) { print "cacheing file ($file) to local ($cache_filename)<p>";} // cache file from net to local $f = fopen($file,"r"); $f2 = fopen($cache_filename,"w+"); while ($r=fread($f,8192) ) { fwrite($f2,$r); } fclose($f2); fclose($f); } // ok, point to (fresh) cached file $handle = fopen($cache_filename, $file_mode); return $handle; } // מיקום התיקיה שאליה אתה רוצה שהקבצים ירדו, הרשאה 777 $location = "./downloads/"; // כתובת HTTP מלאה לקובץ $file_add = $_POST; // הורד את הקובץ לשרת $file = cached_fopen($FILE_ADD, "r", 6, $location); // הצג echo $file; ?>
|
לא בדקתי את הקוד, הזה, אלא פשוט רשמתי אותו עם פונקציה פשוטה,
שים לב תיקיית downloads צריכה להיות עם הרשאה 0777 כדי שיהיה אפשר להוריד אליה.
תעדכן אותי אם צריך עזרה נוספת..
בהצלחה! 