[PHP] Problems downloading files via https in IE 6
I posted this once under another subject, but didn't get any responses. I'm stuck on this, and could really use some help. I have the following php code for downloading a file to the user via the browser: // Open csv file. $fp = fopen(fileOnServer.csv, r); // Set headers for csv download. header(Content-Type:application/csv); header(Content-Disposition:attachment; filename=downloadFile.csv); header(Content-Transfer-Encoding:binary); // Put it to the browser. fpassthru($fp); This works great in Mozilla and IE 6 via http, and it works in Mozilla via https, but for some reason in IE 6 via https, my filename is mysteriously replaced by a truncated version of my page url. This results in an error, because the file (obviously) cannot be found to be downloaded. Is it something I'm doing, or is this an IE problem? And if so, are there any work-arounds? I can get it working with a re-direct to the file after saving it, but that means my server file and my download file have to have the same name, which I would like to avoid. Thanks in advance, Geoff Thompson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems downloading files via https in IE 6
On Sat, 6 Dec 2003, Geoffrey Thompson wrote: header(Content-Type:application/csv); header(Content-Disposition:attachment; filename=downloadFile.csv); header(Content-Transfer-Encoding:binary); fpassthru($fp); This works great in Mozilla and IE 6 via http, and it works in Mozilla via https, but for some reason in IE 6 via https, my filename is mysteriously replaced by a truncated version of my page url. This results in an error, because the file (obviously) cannot be found to be downloaded. Is it something I'm doing, or is this an IE problem? This is the workaround I use for the IE/https download problems. Not sure if it's the same problem, but let me know if this helps: ?php $fname = yourfile.csv; $mimetype = application; $mimesubtype = unknown; $fp = fopen($fname,r); header(Content-type: $mimetype/$mimesubtype); header(sprintf('Content-disposition: attachment; filename=%s', basename($fname))); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Pragma: public); fpassthru($fp); fclose($fp); ? -- Kelly Hallman // Ultrafancy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with files!!!!!
On Sat, 31 Mar 2001 21:31, Ales Kunst wrote: Hi, I have a strange kind of a problem. I'm cannot write to files on a server (i'm having virtual host) where i got my domain name. The server is running Apache 1.3.x and is having php3.0.8 installed. The code looks like this: html body ?php $fcontents = "something"; $fp = fopen("tmp/some.dat", "w"); // trying to open file in my directory tmp/ (i think) fwrite($fp, $fcontents); fclose($fp); ? /body /html I cannot write to directory tmp.I get an error from Netscape that "document contains no data" (i changed the directory mode to 777 (tmp/)). The strangest part is that this script works fine when i am running it at home. At home i tried to run the script under Windows 98 and Linux Mandrake both with Apache 1.3.x with php 4.0.x installed (i don't think this code should have any compatibility problems). On Linux i have put the script to a user directory, just the kind on the server is, and it worked just fine. I think maybe it's the Apache configuration (on the server) which is causing my problem. I would very appreciate any help on this matter (clues what could be wrong). Ales! Probably permissions still - the parent directory must also be accessible to the user that the web server runs as. -- David Robley| WEBMASTER Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet| http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems with files!!!!!
David Robley wrote: On Sat, 31 Mar 2001 21:31, Ales Kunst wrote: Hi, I have a strange kind of a problem. I'm cannot write to files on a server (i'm having virtual host) where i got my domain name. The server is running Apache 1.3.x and is having php3.0.8 installed. The code looks like this: html body ?php $fcontents = "something"; $fp = fopen("tmp/some.dat", "w"); // trying to open file in my directory tmp/ (i think) fwrite($fp, $fcontents); fclose($fp); ? /body /html I cannot write to directory tmp.I get an error from Netscape that "document contains no data" (i changed the directory mode to 777 (tmp/)). The strangest part is that this script works fine when i am running it at home. At home i tried to run the script under Windows 98 and Linux Mandrake both with Apache 1.3.x with php 4.0.x installed (i don't think this code should have any compatibility problems). On Linux i have put the script to a user directory, just the kind on the server is, and it worked just fine. I think maybe it's the Apache configuration (on the server) which is causing my problem. I would very appreciate any help on this matter (clues what could be wrong). Ales! Probably permissions still - the parent directory must also be accessible to the user that the web server runs as. -- David Robley| WEBMASTER Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet| http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] Ah, this may be too simple of an answer but usually the directory is /tmp not tmp/ _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Problems with files!!!!!
I don't know if it's been mentioned or not, but I have found that unless the file exists, I can't open it. Have you verified that the file exists and the user that the script will run as has the appropriate permissions? -Original Message- From: jon [mailto:jon]On Behalf Of Jon Jacob Sent: Sunday, April 01, 2001 7:40 PM Cc: Ales Kunst; [EMAIL PROTECTED] Subject: Re: [PHP] Problems with files! David Robley wrote: On Sat, 31 Mar 2001 21:31, Ales Kunst wrote: Hi, I have a strange kind of a problem. I'm cannot write to files on a server (i'm having virtual host) where i got my domain name. The server is running Apache 1.3.x and is having php3.0.8 installed. The code looks like this: html body ?php $fcontents = "something"; $fp = fopen("tmp/some.dat", "w"); // trying to open file in my directory tmp/ (i think) fwrite($fp, $fcontents); fclose($fp); ? /body /html I cannot write to directory tmp.I get an error from Netscape that "document contains no data" (i changed the directory mode to 777 (tmp/)). The strangest part is that this script works fine when i am running it at home. At home i tried to run the script under Windows 98 and Linux Mandrake both with Apache 1.3.x with php 4.0.x installed (i don't think this code should have any compatibility problems). On Linux i have put the script to a user directory, just the kind on the server is, and it worked just fine. I think maybe it's the Apache configuration (on the server) which is causing my problem. I would very appreciate any help on this matter (clues what could be wrong). Ales! Probably permissions still - the parent directory must also be accessible to the user that the web server runs as. -- David Robley| WEBMASTER Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet| http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] Ah, this may be too simple of an answer but usually the directory is /tmp not tmp/ _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems with files!!!!!
Tyrone Mills wrote: I don't know if it's been mentioned or not, but I have found that unless the file exists, I can't open it. Have you verified that the file exists and the user that the script will run as has the appropriate permissions? I think you are mistaken. According to the PHP manual page, with fopen the option 'w' does the following: "Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. " In this case the line: $fp = fopen("tmp/some.dat", "w"); // trying to open file in my Would create the file if it did not exist, but you make a good point that permissions need to be set. The directory would need to probably be world writable (usually 755 or xrw-rw-rw). _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Problems with files!!!!!
Hi, I have a strange kind of a problem. I'm cannot write to files on a server (i'm having virtual host) where i got my domain name. The server is running Apache 1.3.x and is having php3.0.8 installed. The code looks like this: html body ?php $fcontents = "something"; $fp = fopen("tmp/some.dat", "w"); // trying to open file in my directory tmp/ (i think) fwrite($fp, $fcontents); fclose($fp); ? /body /html I cannot write to directory tmp.I get an error from Netscape that "document contains no data" (i changed the directory mode to 777 (tmp/)). The strangest part is that this script works fine when i am running it at home. At home i tried to run the script under Windows 98 and Linux Mandrake both with Apache 1.3.x with php 4.0.x installed (i don't think this code should have any compatibility problems). On Linux i have put the script to a user directory, just the kind on the server is, and it worked just fine. I think maybe it's the Apache configuration (on the server) which is causing my problem. I would very appreciate any help on this matter (clues what could be wrong). Ales! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems uploading Files
From: "Kilian" [EMAIL PROTECTED] Sent: Thursday, March 22, 2001 7:28 PM The user the webserver process runs under may not have the permission to upload the file. In many cases, the webserver runs as nobody. Thus, if you want to upload a file, nobody needs write-access to the directory into which the file should be uploaded. -- Kilian You sure your name's not Odysseus? :-) "...nobody blinded me..." - Carsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Problems uploading Files
You have to chmod that directory (not needed for FTP of course) Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Renzi, Sebastian [mailto:[EMAIL PROTECTED]] Sent: Friday, March 23, 2001 3:18 AM To: PHP General List Subject: [PHP] Problems uploading Files Hello again ! , i have a script that uploads a file , when i use the function move_uploaded_file() an error raises ,"Permission denied ." ,but if i upload the same file thru an ftp client it works correctly ! Sebastin Renzi Consultora Desarrollo de Sistemas. CODES S.A -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Problems uploading Files
Hello again ! , i have a script that uploads a file , when i use the function move_uploaded_file() an error raises ,"Permission denied ." ,but if i upload the same file thru an ftp client it works correctly ! Sebastin Renzi Consultora Desarrollo de Sistemas. CODES S.A -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Problems uploading Files
Hello Sebastian, What a timely posting! I am trying to figure out how to allow a user (using any internet-connected pc) to upload a file to my PHP-enabled server. I am trying to use PHP and the FTP functions, but can't figure out how to address the file on the user's machine. Any hints from anyone as to how to do this? Or am I on the wrong track, altogether? Someone else suggested that I use an HTML 'upload', but I can't find anything about this in my HTML documentation. Any help much appreciated!!! John -Original Message- From: Renzi, Sebastian [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 22, 2001 1:18 PM To: PHP General List Subject: [PHP] Problems uploading Files Hello again ! , i have a script that uploads a file , when i use the function move_uploaded_file() an error raises ,"Permission denied ." ,but if i upload the same file thru an ftp client it works correctly ! Sebastin Renzi Consultora Desarrollo de Sistemas. CODES S.A -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems uploading Files
Renzi, Sebastian [EMAIL PROTECTED] wrote: Hello again ! , i have a script that uploads a file , when i use the function move_uploaded_file() an error raises ,"Permission denied ." ,but if i upload the same file thru an ftp client it works correctly ! The user the webserver process runs under may not have the permission to upload the file. In many cases, the webserver runs as nobody. Thus, if you want to upload a file, nobody needs write-access to the directory into which the file should be uploaded. -- Kilian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems uploading Files
John Almberg [EMAIL PROTECTED] wrote: [...] Someone else suggested that I use an HTML 'upload', but I can't find anything about this in my HTML documentation. input type="file" ... -- Kilian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problems uploading Files
Sebastian, Apache is running as a user, usually nobody:nobody, or sometimes www:www. That user is trying to move the file when you do the move in php. When you login through an ftp client, a different user is doing the move (you). You need to make sure that the user nobody has enough permissions on your target directory to do the move. Depending on how locked down you want it, there are several options: rwx for owner only, make the owner/group of the directory nobody. rwx for group - change the directory's group to nobody, or add nobody into another group (along with, for instance, yourself) and make that directory belong to this new group. There are several more ways, but you probably want to keep away from 777 permissions on the directory if possible. John - you want to do what Sebastian is doing. Check out Chapter 19. Handling file uploads in the php manual. It has everything you need to get going. Julian -- Julian Wood Multimedia Developer University of Calgary on 3/22/01 11:28 AM, John Almberg at [EMAIL PROTECTED] wrote: Hello Sebastian, What a timely posting! I am trying to figure out how to allow a user (using any internet-connected pc) to upload a file to my PHP-enabled server. I am trying to use PHP and the FTP functions, but can't figure out how to address the file on the user's machine. Any hints from anyone as to how to do this? Or am I on the wrong track, altogether? Someone else suggested that I use an HTML 'upload', but I can't find anything about this in my HTML documentation. Any help much appreciated!!! John -Original Message- From: Renzi, Sebastian [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 22, 2001 1:18 PM To: PHP General List Subject: [PHP] Problems uploading Files Hello again ! , i have a script that uploads a file , when i use the function move_uploaded_file() an error raises ,"Permission denied ." ,but if i upload the same file thru an ftp client it works correctly ! Sebastin Renzi Consultora Desarrollo de Sistemas. CODES S.A -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]