کد فوق را امتحان کرده ایم اما فایل را منتقل میکنه با سایز 0 کیلوبایت !!!!!!
راهکار دیگری ندارید ؟
hegza
June 3rd, 2016, 02:00
کد فوق را امتحان کرده ایم اما فایل را منتقل میکنه با سایز 0 کیلوبایت !!!!!!
راهکار دیگری ندارید ؟
شما ارور لاگ رو نگاه کن ببینید به کدام تابع گیر میده ممکنه get_browser یا fopen بسته یا غیره فعال باشه.
مورد دیگه ممکنه آدرس مبدا برای دسترسی یوزر اگینت تعریف کرده باشه که باعث میشه اجازه دانلود نده. بهرحال از جای دیگر تست کنید + رعایت مورد بالایی
farshid17
June 3rd, 2016, 11:41
اين اسكريپت (http://www.wrock.org/wp-content/uploads/2012/02/remoteupload.zip) صد در صد كار مي كنه خودم كار مي كنم باهاش يك كد ساده هست وقتي لينك فايل قرار مي دي داخلش مثلا up.domain.com ايندكس اسكريپت (http://www.wrock.org/wp-content/uploads/2012/02/remoteupload.zip) است اپلود مي كنه تو سرور و داخل فايل پوشه اش ذخيره مي كنه نياز به ديتابيس و هيچي ديگه نداره يك كد خيلي ساده مي باشد
Rezash
June 3rd, 2016, 11:50
/**
* 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 (!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;
}
اين اسكريپت (http://www.wrock.org/wp-content/uploads/2012/02/remoteupload.zip) صد در صد كار مي كنه خودم كار مي كنم باهاش يك كد ساده هست وقتي لينك فايل قرار مي دي داخلش مثلا up.domain.com ايندكس اسكريپت (http://www.wrock.org/wp-content/uploads/2012/02/remoteupload.zip) است اپلود مي كنه تو سرور و داخل فايل پوشه اش ذخيره مي كنه نياز به ديتابيس و هيچي ديگه نداره يك كد خيلي ساده مي باشد
سپاس فراوان دوست عزیز اما روش استفاده ازش ؟
- - - Updated - - -
/**
* 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 (!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;
}
یا اگر نشد باید از Cron Job استفاده کنید با دستور wget که فایل رو مستقیم دانلود می کنه بدون هیچ اسکریپتی
از اون اسکریپت استفاده کنید در صورت حل نشدن مشکل پست دهید تا آموزش کرون جابز تقدیم شود
farshid17
June 3rd, 2016, 13:07
سپاس فراوان دوست عزیز اما روش استفاده ازش ؟
- - - Updated - - -
دوست عزیز لطف میکنید روش استفاده ازش را هم بفرمائید ؟
دوست این اسکریپت در هاست تتون اپلود می کنید یک فایل کم حجم در یک پوشه مثل up می ریزد (domain.com/up)یا ساب دامین(up.domain.com) بعد در صفحه مرورگر این باز می کنید و لینک از سرور دیگه رو واردش می کنید و دکمه رو فشار می دهید صفجه به لود تبدیل میشه دست به صفحه نزدنید صفحه کامل لود شود دوبار مثل صفحه اول اسکریپت تبدیل بشود
و فایل تو چقدر حجم دارد
و اینکه می تونید دسترسی بدید براتون انجام میشه ولی کارش ساده هست
mohammad.ah
June 3rd, 2016, 13:24
چطور میشه از لحاظ امنیتی جلوی اینکارو گرفت تا این انتقال صورت نگیره ؟
kianesfahan
June 3rd, 2016, 22:00
دوست این اسکریپت در هاست تتون اپلود می کنید یک فایل کم حجم در یک پوشه مثل 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
کد فوق جواب میدهد فایل را منتقل میکند اما نصف حجم فایل را که منتقل کرد ارور :
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'.