473,406 Members | 2,705 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,406 software developers and data experts.

FOPEN and name of file

Hi friends.
i have a file 'file.php' with a little script
Expand|Select|Wrap|Line Numbers
  1. $filename = "mydocument.doc";
  2. fopen($filename, "r");
when i load file.php FF and IE open a window that asks if i want open or save the file 'file.php'

Why and how put right?
obviously i would open mydocument.doc...

Thanks a lot.
Regards
Jun 29 '11 #1
2 1668
ok not a bad start..
if I tell you that they are two days that I try to solve it you do not believe me!

i resolved with an "header" like this
Expand|Select|Wrap|Line Numbers
  1. $filename = "mydocument.doc";
  2. $handle = fopen($filename, "r");
  3. if ($handle) {
  4. header('Content-Type: application/vnd.ms-word');
  5. header("Content-Disposition: attachment; filename=\"$filename\"");
  6. }
I hope this is helpful to someone.
Thanks anyway, forgive me.
Regards
Jun 29 '11 #2
Markus
6,050 Expert 4TB
The reason the browser asks if you want to download the data is because it doesn't know how to interpret it. By giving the browser information such as the content-type and file name it can better handle the data.
Jun 29 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: ARGENTINA | last post by:
I ve been trying php script sent by rchaplin and all goes ok automatically appears a new file copied after script execution but it appears a messaje like next one: Warning: fopen(): URL...
2
by: Loopy | last post by:
I'm trying to write a script that will connect to an external site so that I can get access referer information in a database on another one of my sites. I got errors, so I tried to write a script...
1
by: clusardi2k | last post by:
Hello, I have a shared drive on SGI, Linux, and Windows. The fact that I'm using a shared drive may be mute information. The problem is within the same program a second call to fopen does not...
7
by: clusardi2k | last post by:
Hello, I have a shared drive on SGI, Linux, and Windows. A second call to fopen doesn't create the file if it has been deleted. I would like to use fopen for its pointer return value to...
2
by: msuk | last post by:
All, I have a C# COM+ component and have created a strong name file using the sn.exe. In my AssembleyInfo.cs I have added the following: My question is when I deploy the COM+ component to...
7
by: Efi Merdler | last post by:
Hi, I created a very simple application that reads and writes to a file, I was wondering if fopen when opening a file for write access blocks this file, i.e. when another user runs this script the...
3
by: Suman | last post by:
I don't seem to recall having seen any other structure defined in the standard libraries that has an all uppercase name. FILE, is a glaring exception. Does anyone know as to why this is so? I...
5
by: Brian | last post by:
Hi I have a problem in opening url using 'file'. I searched many other discussion groups and tried suggestions, but could not resolve this problem. e.g <?php $myfile =...
4
by: Nagrik | last post by:
Hello Group, I have to support 200 Gigabyte support to open a file in my program. My program exits with open("/mnt/d1/tmp/<file name>", O_RDONLY) = -1 EFBIG (File too large) This open...
5
by: phpnewbie26 | last post by:
I've been having trouble trying to open a file. It outputs fopen(/projects/CCPROT/ts_classes) : failed to open stream: No such file or directory in /mnt/raid/www/intra/admin/ts2/test2.php on line 72...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.