Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
download file (film)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
ToDD



Joined: 05 May 2005
Posts: 83
Location: Zagreb

PostPosted: 25.09.2006 21:20    Post subject: download file (film) Add user to your forum ignore list Reply with quote

uglavnom u bazi imam stavljen url filea i zelim da se moze skinuti.

neznam zasto ovo ne radi, prvo mi čeka 16 sekundi i onda mi se pojavi file od 0Kb, na localhostu mi sve ljepo radi, a ovdje nikako.

usput: hosting je inside.hr
url je potpuno točan
mysql naredbe prije su također točne, problem je baš u ovim hederima

[PHP]
$file = "download/fileovi/" . $r[url];
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-Length: ".filesize($file));
header("Content-Disposition: attachment; filename=\"" . basename($file)."\"");
readfile($file);
[/PHP]
Back to top
View user's profile Send private message MSN Messenger
ToDD



Joined: 05 May 2005
Posts: 83
Location: Zagreb

PostPosted: 26.09.2006 12:27    Post subject: Add user to your forum ignore list Reply with quote

nitko nista?
a joj
Back to top
View user's profile Send private message MSN Messenger
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 26.09.2006 12:41    Post subject: Add user to your forum ignore list Reply with quote

Takve stvari je dosta tesko debugirati, pogotovo bez pristupa serveru ili bar live verziji skripte da se mogu vidjeti konkretni headeri koje server salje...

Jel koristis output buffering? Ako da, moguce je da ti negdje izleti neki whitespace prije nego ode file, a ako nije whitespace, mozda te session zafrkava... Vidi session_write_close(), ob_flush(), flush() u php manualu.

Moguce je i da ti je file koji isporucuje download snimljen kao utf-8 sa BOMom, u kojem slucaju (ovisno o verziji apache-a i php-a) BOM odleti van prije svega, i zato nista ne radi.

Moguce je i da koristis neke druge headere na nekom drugom mjestu prije nego sto ovaj file php dodje na red, i da se u tom procesu neki od header-a prepise...

U svakom slucaju, header("Content-Type: application/force-download"); ne postoji u HTTP specifikaciji...

Evo ti neki set header-a s kojima sam u vecini slucajeva uspio inicirati download dialog na dosta browsera / os-ova...

Code:

    header('Content-Disposition: attachment; filename="'.$filename.'"');
    header('Content-Type: application/octet-stream');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . (string)(filesize($file_to_send)));
    // ovdje sada ide readfile() ili fpassthru() ili nesto vec
    readfile($file);
    exit;


Takodjer, postavi error_reporting(E_ALL) da vidis da ne puca negdje drugdje.

P.S.
Kod downloadanja fileova ovakvom metodom, vodi racuna da ti datoteka za download nije velika, jer ju funkcija readfile() mora cijelu procitati i pljunuti van...

Ako moras vece fileove downloadati (preko par MB), ne bi skodilo da si napises funkciju koja ce citat po x bajtova file-a i flushati buffer nakon sto procita tih x bajtova, i tako dok ne procita cijeli file... Cisto zbog toga da ti web server i/ili php procesi ne pojedu previse memorije...

_________________
[+]I[+]am[+]my[+]own[+]religion[+]
Back to top
View user's profile Send private message Visit poster's website Twitter profile
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 26.09.2006 12:44    Post subject: Add user to your forum ignore list Reply with quote

Eh da, ako su filmovi (veliki fileovi), postavi i:
Code:
set_time_limit(0);

jer je lako moguce da ti se desi script timeout, odnosno, da se skripta vrti duze od dozvoljenog... mozda je u php.ini-u postavljeno da je script timeout 16 sekundi? vidi sta kaze phpinfo() po tom pitanju...

_________________
[+]I[+]am[+]my[+]own[+]religion[+]
Back to top
View user's profile Send private message Visit poster's website Twitter profile
ToDD



Joined: 05 May 2005
Posts: 83
Location: Zagreb

PostPosted: 26.09.2006 16:27    Post subject: Add user to your forum ignore list Reply with quote

stavio sam tvoj kod upalio error_reporting i sad mi izbacuje

Notice: Use of undefined constant url - assumed 'url' in /home/brklja/public_html/cms/download/film_header.php on line 20
za header('Content-Disposition: attachment; filename="'.basename($r[url]).'"');

wtf? sta to znaci?
Back to top
View user's profile Send private message MSN Messenger
carr



Joined: 13 Nov 2003
Posts: 1397
Location: Karlovac

PostPosted: 26.09.2006 16:36    Post subject: Add user to your forum ignore list Reply with quote

ToDD wrote:
stavio sam tvoj kod upalio error_reporting i sad mi izbacuje

Notice: Use of undefined constant url - assumed 'url' in /home/brklja/public_html/cms/download/film_header.php on line 20
za header('Content-Disposition: attachment; filename="'.basename($r[url]).'"');

wtf? sta to znaci?

vjerojatno $r[url] nije nista, tj. mozda si trebao $r['url'] a mozda u $r uopce nema nista.

napravi var_dump($r) pa vidi, i echoaj taj cijeli header pa daj njega ako ne radi svejedno

_________________
Bolje biti malo lud, nego malo pametan.
Back to top
View user's profile Send private message Visit poster's website
ToDD



Joined: 05 May 2005
Posts: 83
Location: Zagreb

PostPosted: 26.09.2006 16:51    Post subject: Add user to your forum ignore list Reply with quote

Code:

echo 'file_exist:' . file_exists('download/fileovi/' . $r[url]) . '<br>';
      
   echo 'Content-Disposition: attachment; filename="'.basename($r[url]).'"<br>';
    echo 'Content-Type: application/octet-stream<br>';
    echo 'Content-Transfer-Encoding: binary<br>';
    echo 'Content-Length: ' . (string)($r[velicina]) . '<br>';
    // ovdje sada ide readfile() ili fpassthru() ili nesto vec
    echo 'download/fileovi/' . $r[url];


i dobijem ovo

file_exist:1
Content-Disposition: attachment; filename="[www.budalizacija.hr]_nikad-ne-reci-nikad.wmv"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-Length: 1038182
download/fileovi/filmovi/[www.budalizacija.hr]_nikad-ne-reci-nikad.wmv



niti jedan header nije prije toga definiran, stvarno neznam u cemu je problem
Back to top
View user's profile Send private message MSN Messenger
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 26.09.2006 16:57    Post subject: Add user to your forum ignore list Reply with quote

Sto se E_NOTICE tice, fale ti single quoteovi oko imena ključa u $r nizu... dakle:
Code:
$r['url']


Ista stvar i sa $r['velicina']... I vjerojatno sa svakim arrayem koji koristis u svom kodu...

Da li to utjece na download ili ne, ne znam, prvo sredi sve da nema nikakve greske ili nezeljenog outputa od strane php-a, onda mozemo prckati dalje...

_________________
[+]I[+]am[+]my[+]own[+]religion[+]
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group