473,408 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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 help? THanks in advance
Jun 27 '08 #1
10 1463
..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 help? 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
Jun 27 '08 #2
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.dewrote:
.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 help? 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
Jun 27 '08 #3
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.dewrote:
.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 help? 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
Jun 27 '08 #4
..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
Jun 27 '08 #5
Yes, it shows

./uploads/files

What can i do to change that???

On 19 Jun, 22:16, Michael Fesser <neti...@gmx.dewrote:
.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
Jun 27 '08 #6
On Jun 20, 9:57*am, Pépê <josemariabar...@gmail.comwrote:
On 19 Jun, 22:16, Michael Fesser <neti...@gmx.dewrote:
.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.
MichaYes, 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; ?>

Jun 27 '08 #7
On 20 Jun, 12:35, Captain Paralytic <paul_laut...@yahoo.comwrote:
On Jun 20, 9:57*am, Pépê <josemariabar...@gmail.comwrote:
On 19 Jun, 22:16, Michael Fesser <neti...@gmx.dewrote:
.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.
MichaYes, 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..
Jun 27 '08 #8
On Jun 20, 3:16*pm, Pépê <josemariabar...@gmail.comwrote:
On 20 Jun, 12:35, Captain Paralytic <paul_laut...@yahoo.comwrote:


On Jun 20, 9:57*am, Pépê <josemariabar...@gmail.comwrote:
On 19 Jun, 22:16, Michael Fesser <neti...@gmx.dewrote:
.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.
MichaYes, 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.
Jun 27 '08 #9
On 20 Jun, 15:35, Captain Paralytic <paul_laut...@yahoo.comwrote:
On Jun 20, 3:16*pm, Pépê <josemariabar...@gmail.comwrote:
On 20 Jun, 12:35, Captain Paralytic <paul_laut...@yahoo.comwrote:
On Jun 20, 9:57*am, Pépê <josemariabar...@gmail.comwrote:
On 19 Jun, 22:16, Michael Fesser <neti...@gmx.dewrote:
.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.
MichaYes, 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
Jun 27 '08 #10
..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
Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to...
23
by: Lamberti Fabrizio | last post by:
Hi all, I've to access to a network file from an asp pages. I've red a lot of things on old posts and on Microsoft article but I can't still solve my problem. I've got two server inside the...
1
by: BW | last post by:
I am creating an upload/download function for an extranet site. Files will be uploaded to directory based upon the users login and associated project. The function works as long as I use "c:\Temp"...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
9
by: CGW | last post by:
I asked the question yesterday, but know better how to ask it, today: I'm trying to use the File.Copy method to copy a file from a client to server (.Net web app under IIS ). It looks to me that...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.