PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > get a pdf file from server
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
get a pdf file from server

Réponse
 
LinkBack Outils de la discussion
Vieux 19/06/2008, 18h20   #1
Pépê
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut get a pdf file from server

Hello.

Im new to php and i had experience in ASP.

IM trying to get a pdf file from a remote folder and what happens is
that opens a new page.

Here is the code:

<a href="./uploads/files/<?php echo $pdf ?>">Get File!</a>

The $pdf has the value from the field 'file_pdf' and the type is
varchar. Example: "test.pdf".

Any ? THanks in advance
  Réponse avec citation
Vieux 19/06/2008, 19h18   #2
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get a pdf file from server

..oO(Pépê)

>IM trying to get a pdf file from a remote folder and what happens is
>that opens a new page.
>
>Here is the code:
>
><a href="./uploads/files/<?php echo $pdf ?>">Get File!</a>
>
>The $pdf has the value from the field 'file_pdf' and the type is
>varchar. Example: "test.pdf".


Looks OK.

>Any ? THanks in advance


What do you get? Does your browser display the PDF as plain text? Then
the server doesn't deliver it with the correct content type.

Micha
  Réponse avec citation
Vieux 19/06/2008, 20h39   #3
Pépê
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get a pdf file from server

Thanks for the answer Micha.

Well, when i try it on my local server i go to another page and what i
see is a page with a link with the name of the pdf file.

How can i see if it is the correct content type?


Best Regards

On 19 Jun, 19:18, Michael Fesser <neti...@gmx.de> wrote:
> .oO(Pépê)
>
> >IM trying to get a pdf file from a remote folder and what happens is
> >that opens a new page.

>
> >Here is the code:

>
> ><a href="./uploads/files/<?php echo $pdf ?>">Get File!</a>

>
> >The $pdf has the value from the field 'file_pdf' and the type is
> >varchar. Example: "test.pdf".

>
> Looks OK.
>
> >Any ? THanks in advance

>
> What do you get? Does your browser display the PDF as plain text? Then
> the server doesn't deliver it with the correct content type.
>
> Micha


  Réponse avec citation
Vieux 19/06/2008, 20h40   #4
Pépê
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get a pdf file from server

Thanks for the answer Micha.

Well, when i try it on my local server i go to another page and what i
see is a page with a link with the name of the pdf file.

How can i see if it is the correct content type?


Best Regards

On 19 Jun, 19:18, Michael Fesser <neti...@gmx.de> wrote:
> .oO(Pépê)
>
> >IM trying to get a pdf file from a remote folder and what happens is
> >that opens a new page.

>
> >Here is the code:

>
> ><a href="./uploads/files/<?php echo $pdf ?>">Get File!</a>

>
> >The $pdf has the value from the field 'file_pdf' and the type is
> >varchar. Example: "test.pdf".

>
> Looks OK.
>
> >Any ? THanks in advance

>
> What do you get? Does your browser display the PDF as plain text? Then
> the server doesn't deliver it with the correct content type.
>
> Micha


  Réponse avec citation
Vieux 19/06/2008, 22h16   #5
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get a pdf file from server

..oO(Pépê)

>Thanks for the answer Micha.
>
>Well, when i try it on my local server i go to another page and what i
>see is a page with a link with the name of the pdf file.


The script just prints a URL with the filename of the PDF. In the
resulting HTML source code it should look like

<a href="./uploads/files/test.pdf">Get File!</a>

You should check that. If for whatever reason the URL would be just

../uploads/files/

then you would probably get a server-generated index page containing a
list of the directory content. This would mean the problem is your PHP.

>How can i see if it is the correct content type?


If it's online, you can use <http://web-sniffer.net/>, for a local check
the "Live HTTP Headers" extension for Firefox is probably the easiest
way to examine the answer from the server. What matters is the Content-
Type header in the response, it describes of what type the returned data
is and how the browser should handle it. For PDFs the returned content
type should be "application/pdf", which will allow browsers to either
show the PDF inline (if a plugin is available) or to launch an external
viewer.

Micha
  Réponse avec citation
Vieux 20/06/2008, 09h57   #6
Pépê
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get a pdf file from server

Yes, it shows

./uploads/files

What can i do to change that???

On 19 Jun, 22:16, Michael Fesser <neti...@gmx.de> wrote:
> .oO(Pépê)
>
> >Thanks for the answer Micha.

>
> >Well, when i try it on my local server i go to another page and what i
> >see is a page with a link with the name of the pdf file.

>
> The script just prints a URL with the filename of the PDF. In the
> resulting HTML source code it should look like
>
> <a href="./uploads/files/test.pdf">Get File!</a>
>
> You should check that. If for whatever reason the URL would be just
>
> ./uploads/files/
>
> then you would probably get a server-generated index page containing a
> list of the directory content. This would mean the problem is your PHP.
>
> >How can i see if it is the correct content type?

>
> If it's online, you can use <http://web-sniffer.net/>, for a local check
> the "Live HTTP Headers" extension for Firefox is probably the easiest
> way to examine the answer from the server. What matters is the Content-
> Type header in the response, it describes of what type the returned data
> is and how the browser should handle it. For PDFs the returned content
> type should be "application/pdf", which will allow browsers to either
> show the PDF inline (if a plugin is available) or to launch an external
> viewer.
>
> Micha


  Réponse avec citation
Vieux 20/06/2008, 12h35   #7
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get a pdf file from server

On Jun 20, 9:57am, Pépê <josemariabar...@gmail.com> wrote:
> On 19 Jun, 22:16, Michael Fesser <neti...@gmx.de> wrote:
>
>
>
> > .oO(Pépê)

>
> > >Thanks for the answer Micha.

>
> > >Well, when i try it on my local server i go to another page and what i
> > >see is a page with a link with the name of the pdf file.

>
> > The script just prints a URL with the filename of the PDF. In the
> > resulting HTML source code it should look like

>
> > <a href="./uploads/files/test.pdf">Get File!</a>

>
> > You should check that. If for whatever reason the URL would be just

>
> > ./uploads/files/

>
> > then you would probably get a server-generated index page containing a
> > list of the directory content. This would mean the problem is your PHP.

>
> > >How can i see if it is the correct content type?

>
> > If it's online, you can use <http://web-sniffer.net/>, for a local check
> > the "Live HTTP Headers" extension for Firefox is probably the easiest
> > way to examine the answer from the server. What matters is the Content-
> > Type header in the response, it describes of what type the returned data
> > is and how the browser should handle it. For PDFs the returned content
> > type should be "application/pdf", which will allow browsers to either
> > show the PDF inline (if a plugin is available) or to launch an external
> > viewer.

>
> > Micha> Yes, it shows

>
> ./uploads/files
>
> What can i do to change that???
>

The first thing to do is to please stop top posting (top posting
fixed).

Next I would suggest reporting the bug you have found as it is pretty
much impossible for the output to show:
./uploads/files
However, if I assume that you have made a copy'n'paste error and teh
output actually shows:
./uploads/files/
then you should look at why you are getting nothing output by your
echo statement, which is most likely because there is nothng in the
variable $pdf.

Since you do not tell us how $pdf is supposed to get populated, there
is not much more we can tell you.

BTW, <?php echo $pdf ?> should really say <?php echo $pdf; ?>

  Réponse avec citation
Vieux 20/06/2008, 15h16   #8
Pépê
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get a pdf file from server

On 20 Jun, 12:35, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On Jun 20, 9:57am, Pépê <josemariabar...@gmail.com> wrote:
>
> > On 19 Jun, 22:16, Michael Fesser <neti...@gmx.de> wrote:

>
> > > .oO(Pépê)

>
> > > >Thanks for the answer Micha.

>
> > > >Well, when i try it on my local server i go to another page and whati
> > > >see is a page with a link with the name of the pdf file.

>
> > > The script just prints a URL with the filename of the PDF. In the
> > > resulting HTML source code it should look like

>
> > > <a href="./uploads/files/test.pdf">Get File!</a>

>
> > > You should check that. If for whatever reason the URL would be just

>
> > > ./uploads/files/

>
> > > then you would probably get a server-generated index page containing a
> > > list of the directory content. This would mean the problem is your PHP.

>
> > > >How can i see if it is the correct content type?

>
> > > If it's online, you can use <http://web-sniffer.net/>, for a local check
> > > the "Live HTTP Headers" extension for Firefox is probably the easiest
> > > way to examine the answer from the server. What matters is the Content-
> > > Type header in the response, it describes of what type the returned data
> > > is and how the browser should handle it. For PDFs the returned content
> > > type should be "application/pdf", which will allow browsers to either
> > > show the PDF inline (if a plugin is available) or to launch an external
> > > viewer.

>
> > > Micha> Yes, it shows

>
> > ./uploads/files

>
> > What can i do to change that???

>
> The first thing to do is to please stop top posting (top posting
> fixed).
>
> Next I would suggest reporting the bug you have found as it is pretty
> much impossible for the output to show:
> ./uploads/files
> However, if I assume that you have made a copy'n'paste error and teh
> output actually shows:
> ./uploads/files/
> then you should look at why you are getting nothing output by your
> echo statement, which is most likely because there is nothng in the
> variable $pdf.
>
> Since you do not tell us how $pdf is supposed to get populated, there
> is not much more we can tell you.
>
> BTW, <?php echo $pdf ?> should really say <?php echo $pdf; ?>


The problem was solved when i uploaded from local to internet....
In the internet it is running normally but locally dont..strange..
  Réponse avec citation
Vieux 20/06/2008, 15h35   #9
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get a pdf file from server

On Jun 20, 3:16pm, Pépê <josemariabar...@gmail.com> wrote:
> On 20 Jun, 12:35, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>
>
>
>
> > On Jun 20, 9:57am, Pépê <josemariabar...@gmail.com> wrote:

>
> > > On 19 Jun, 22:16, Michael Fesser <neti...@gmx.de> wrote:

>
> > > > .oO(Pépê)

>
> > > > >Thanks for the answer Micha.

>
> > > > >Well, when i try it on my local server i go to another page and what i
> > > > >see is a page with a link with the name of the pdf file.

>
> > > > The script just prints a URL with the filename of the PDF. In the
> > > > resulting HTML source code it should look like

>
> > > > <a href="./uploads/files/test.pdf">Get File!</a>

>
> > > > You should check that. If for whatever reason the URL would be just

>
> > > > ./uploads/files/

>
> > > > then you would probably get a server-generated index page containing a
> > > > list of the directory content. This would mean the problem is your PHP.

>
> > > > >How can i see if it is the correct content type?

>
> > > > If it's online, you can use <http://web-sniffer.net/>, for a local check
> > > > the "Live HTTP Headers" extension for Firefox is probably the easiest
> > > > way to examine the answer from the server. What matters is the Content-
> > > > Type header in the response, it describes of what type the returneddata
> > > > is and how the browser should handle it. For PDFs the returned content
> > > > type should be "application/pdf", which will allow browsers to either
> > > > show the PDF inline (if a plugin is available) or to launch an external
> > > > viewer.

>
> > > > Micha> Yes, it shows

>
> > > ./uploads/files

>
> > > What can i do to change that???

>
> > The first thing to do is to please stop top posting (top posting
> > fixed).

>
> > Next I would suggest reporting the bug you have found as it is pretty
> > much impossible for the output to show:
> > ./uploads/files
> > However, if I assume that you have made a copy'n'paste error and teh
> > output actually shows:
> > ./uploads/files/
> > then you should look at why you are getting nothing output by your
> > echo statement, which is most likely because there is nothng in the
> > variable $pdf.

>
> > Since you do not tell us how $pdf is supposed to get populated, there
> > is not much more we can tell you.

>
> > BTW, <?php echo $pdf ?> should really say <?php echo $pdf; ?>

>
> The problem was solved when i uploaded from local to internet....
> In the internet it is running normally but locally dont..strange..- Hide quoted text -
>
> - Show quoted text -


Well you do not show us where you get the value of $pdf from (as I
already said), but is it possible that you have register_globals set
on on the internet? If so you need to fix the program without
register_globals.
  Réponse avec citation
Vieux 20/06/2008, 16h06   #10
Pépê
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get a pdf file from server

On 20 Jun, 15:35, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On Jun 20, 3:16pm, Pépê <josemariabar...@gmail.com> wrote:
>
>
>
> > On 20 Jun, 12:35, Captain Paralytic <paul_laut...@yahoo.com> wrote:

>
> > > On Jun 20, 9:57am, Pépê <josemariabar...@gmail.com> wrote:

>
> > > > On 19 Jun, 22:16, Michael Fesser <neti...@gmx.de> wrote:

>
> > > > > .oO(Pépê)

>
> > > > > >Thanks for the answer Micha.

>
> > > > > >Well, when i try it on my local server i go to another page and what i
> > > > > >see is a page with a link with the name of the pdf file.

>
> > > > > The script just prints a URL with the filename of the PDF. In the
> > > > > resulting HTML source code it should look like

>
> > > > > <a href="./uploads/files/test.pdf">Get File!</a>

>
> > > > > You should check that. If for whatever reason the URL would be just

>
> > > > > ./uploads/files/

>
> > > > > then you would probably get a server-generated index page containing a
> > > > > list of the directory content. This would mean the problem is your PHP.

>
> > > > > >How can i see if it is the correct content type?

>
> > > > > If it's online, you can use <http://web-sniffer.net/>, for a local check
> > > > > the "Live HTTP Headers" extension for Firefox is probably the easiest
> > > > > way to examine the answer from the server. What matters is the Content-
> > > > > Type header in the response, it describes of what type the returned data
> > > > > is and how the browser should handle it. For PDFs the returned content
> > > > > type should be "application/pdf", which will allow browsers to either
> > > > > show the PDF inline (if a plugin is available) or to launch an external
> > > > > viewer.

>
> > > > > Micha> Yes, it shows

>
> > > > ./uploads/files

>
> > > > What can i do to change that???

>
> > > The first thing to do is to please stop top posting (top posting
> > > fixed).

>
> > > Next I would suggest reporting the bug you have found as it is pretty
> > > much impossible for the output to show:
> > > ./uploads/files
> > > However, if I assume that you have made a copy'n'paste error and teh
> > > output actually shows:
> > > ./uploads/files/
> > > then you should look at why you are getting nothing output by your
> > > echo statement, which is most likely because there is nothng in the
> > > variable $pdf.

>
> > > Since you do not tell us how $pdf is supposed to get populated, there
> > > is not much more we can tell you.

>
> > > BTW, <?php echo $pdf ?> should really say <?php echo $pdf; ?>

>
> > The problem was solved when i uploaded from local to internet....
> > In the internet it is running normally but locally dont..strange..- Hide quoted text -

>
> > - Show quoted text -

>
> Well you do not show us where you get the value of $pdf from (as I
> already said), but is it possible that you have register_globals set
> on on the internet? If so you need to fix the program without
> register_globals.


THe register_globals is set to off.

I get the value of $pdf from the database. Is that it?sorry but i dont
understand..newbie here
  Réponse avec citation
Vieux 20/06/2008, 17h50   #11
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get a pdf file from server

..oO(Captain Paralytic)

>However, if I assume that you have made a copy'n'paste error and teh
>output actually shows:
>./uploads/files/
>then you should look at why you are getting nothing output by your
>echo statement, which is most likely because there is nothng in the
>variable $pdf.


First thing to check is the local php.ini for correct error settings:

display_errors = on
error_reporting = E_ALL|E_STRICT

PHP might show a notice in this case. Then some error handling in the
database part might be useful as well.

>Since you do not tell us how $pdf is supposed to get populated, there
>is not much more we can tell you.
>
>BTW, <?php echo $pdf ?> should really say <?php echo $pdf; ?>


Both work. In PHP the semicolon is a statement separator, not a
terminator.

Micha
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 06h39.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,27942 seconds with 19 queries