سلام دوستان .
چه طور میشود یک فایل را بین دو هاست با استفاده از کد های php و سرعت و اینترنت سرور انتقال داد ؟
یکسری کدهایی در نت وجود دارد انها را تست میکنیم فایل جابه جا نمی شود !!!!!
راه حلی دوستان دارند ؟ ضروری هست
سلام دوستان .
چه طور میشود یک فایل را بین دو هاست با استفاده از کد های php و سرعت و اینترنت سرور انتقال داد ؟
یکسری کدهایی در نت وجود دارد انها را تست میکنیم فایل جابه جا نمی شود !!!!!
راه حلی دوستان دارند ؟ ضروری هست
کد فوق را امتحان کرده ایم اما فایل را منتقل میکنه با سایز 0 کیلوبایت !!!!!!
راهکار دیگری ندارید ؟
پروردگارا مرا فهم ده:: تا متوقع نباشم. دنیا و مردمانش باید مطابق میل من رفتار کنند.
ویرایش توسط farshid17 : June 3rd, 2016 در ساعت 11:42
ویرایش توسط Z.eus : June 3rd, 2016 در ساعت 12:26
ServerSaz.com | Fast and Reliable VPS, Dedicated Server █
24x7x365 Technical Support - 99.9% Uptime Guarantee █
Join us on Telegram | Live Chat █
دوست این اسکریپت در هاست تتون اپلود می کنید یک فایل کم حجم در یک پوشه مثل up می ریزد (domain.com/up)یا ساب دامین(up.domain.com) بعد در صفحه مرورگر این باز می کنید و لینک از سرور دیگه رو واردش می کنید و دکمه رو فشار می دهید صفجه به لود تبدیل میشه دست به صفحه نزدنید صفحه کامل لود شود دوبار مثل صفحه اول اسکریپت تبدیل بشود
و فایل تو چقدر حجم دارد
و اینکه می تونید دسترسی بدید براتون انجام میشه ولی کارش ساده هست
تشکر دوست عزیز .
روالی که فرمودید را انجام دادیم اما چند ثانیه بعد لود تمام شد و صفحه همانند اول شد اما فایل انتقال پیدا نکرد !!!!
وقتی فایل error_log را بررسی کردیم به موارد ذیل برخورد کردیم :
[03-Jun-2016 21:29:49 Asia/Tehran] PHP Warning: fopen(ente******/wp-admin.zip): failed to open stream: No such file or directory in /home/men/public_html/index.php on line 31
[03-Jun-2016 21:29:49 Asia/Tehran] PHP Notice: Undefined variable: newf in /home/men/public_html/index.php on line 45
چرا ؟ دلیل آن چیست ؟
- - - Updated - - -
تشکر دوست عزیز پسورد را در فایل index.php وارد میکنیم و وقتی اطلاعات را در اسکریپت میزنیم و روی دکمه دانلود فایل میزنیم صفحه میشود و هیچ فایلی انتقال نمی یابد !!!!!!
در فایل error_log ارور های ذیل ثبت شده است :
[03-Jun-2016 21:36:31 Asia/Tehran] PHP Notice: Undefined index: submit in /home/men/public_html/index.php on line 24
[03-Jun-2016 21:37:17 Asia/Tehran] PHP Notice: Use of undefined constant from - assumed 'from' in /home/men/public_html/index.php on line 28
[03-Jun-2016 21:37:17 Asia/Tehran] PHP Notice: Use of undefined constant from - assumed 'from' in /home/men/public_html/index.php on line 34
[03-Jun-2016 21:37:17 Asia/Tehran] PHP Notice: Use of undefined constant to - assumed 'to' in /home/men/public_html/index.php on line 36
[03-Jun-2016 21:37:18 Asia/Tehran] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 133959681 bytes) in /home/men/public_html/index.php on line 50
[03-Jun-2016 21:37:23 Asia/Tehran] PHP Notice: Use of undefined constant from - assumed 'from' in /home/men/public_html/index.php on line 28
[03-Jun-2016 21:37:23 Asia/Tehran] PHP Notice: Use of undefined constant from - assumed 'from' in /home/men/public_html/index.php on line 34
[03-Jun-2016 21:37:23 Asia/Tehran] PHP Notice: Use of undefined constant to - assumed 'to' in /home/men/public_html/index.php on line 36
[03-Jun-2016 21:37:24 Asia/Tehran] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 133959681 bytes) in /home/men/public_html/index.php on line 50
[03-Jun-2016 21:38:12 Asia/Tehran] PHP Notice: Undefined index: submit in /home/men/public_html/index.php on line 24
[03-Jun-2016 21:38:23 Asia/Tehran] PHP Notice: Use of undefined constant from - assumed 'from' in /home/men/public_html/index.php on line 28
[03-Jun-2016 21:38:23 Asia/Tehran] PHP Notice: Use of undefined constant from - assumed 'from' in /home/men/public_html/index.php on line 34
[03-Jun-2016 21:38:23 Asia/Tehran] PHP Notice: Use of undefined constant to - assumed 'to' in /home/men/public_html/index.php on line 36
[03-Jun-2016 21:38:24 Asia/Tehran] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 133959681 bytes) in /home/men/public_html/index.php on line 50
مشکل از چی هست ؟
- - - Updated - - -
تشکر دوست عزیز .
کد فوق جواب میدهد فایل را منتقل میکند اما نصف حجم فایل را که منتقل کرد ارور :
Request Timeout
This request takes too long to process, it is timed out by the server. If it should not be timed out, please contact administrator of this web site to increase 'Connection Timeout'.
را میدهد .
باید چه کنیم ؟
استفاده :کد PHP:
/**
* Copy remote file over HTTP one small chunk at a time.
*
* @param $infile The full URL to the remote file
* @param $outfile The path where to save the file
*/
function copyfile_chunked($infile, $outfile) {
$chunksize = 10 * (1024 * 1024); // 10 Megs
/**
* parse_url breaks a part a URL into it's parts, i.e. host, path,
* query string, etc.
*/
$parts = parse_url($infile);
$i_handle = fsockopen($parts['host'], 80, $errstr, $errcode, 5);
$o_handle = fopen($outfile, 'wb');
if ($i_handle == false || $o_handle == false) {
return false;
}
if (!empty($parts['query'])) {
$parts['path'] .= '?' . $parts['query'];
}
/**
* Send the request to the server for the file
*/
$request = "GET {$parts['path']} HTTP/1.1\r\n";
$request .= "Host: {$parts['host']}\r\n";
$request .= "User-Agent: Mozilla/5.0\r\n";
$request .= "Keep-Alive: 115\r\n";
$request .= "Connection: keep-alive\r\n\r\n";
fwrite($i_handle, $request);
/**
* Now read the headers from the remote server. We'll need
* to get the content length.
*/
$headers = array();
while(!feof($i_handle)) {
$line = fgets($i_handle);
if ($line == "\r\n") break;
$headers[] = $line;
}
/**
* Look for the Content-Length header, and get the size
* of the remote file.
*/
$length = 0;
foreach($headers as $header) {
if (stripos($header, 'Content-Length:') === 0) {
$length = (int)str_replace('Content-Length: ', '', $header);
break;
}
}
/**
* Start reading in the remote file, and writing it to the
* local file one chunk at a time.
*/
$cnt = 0;
while(!feof($i_handle)) {
$buf = '';
$buf = fread($i_handle, $chunksize);
$bytes = fwrite($o_handle, $buf);
if ($bytes == false) {
return false;
}
$cnt += $bytes;
/**
* We're done reading when we've reached the conent length
*/
if ($cnt >= $length) break;
}
fclose($i_handle);
fclose($o_handle);
return $cnt;
}
منبع :کد PHP:
copyfile_chunked('http://somesite.com/somefile.jpg', '/local/path/somefile.jpg');
http://stackoverflow.com/questions/4...w-memory-usage
اینم خوبه :
http://stackoverflow.com/a/6409494
ویرایش توسط Rezash : June 3rd, 2016 در ساعت 11:51
در حال حاضر 1 کاربر در حال مشاهده این موضوع است. (0 کاربران و 1 مهمان ها)