954,170 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

open save dialog box error

i have a question. my function works in a way that once user clicks the link, the open save dialog box will pop out then the user have a option to choose whether to open or save the mp3 file.

The problem is the save function can wrk meaning if user save the mp3 file and listen, everything is ok. But when the user try to open the file straight away, the mp3 file cannot be open. There will be an error msg. I do not knoe how to go abt to solve this error.

is there a way to enable the user to open the file straight away once the link is clicked? i have try to put a link to the mp3 file but that would result in the user from seeing the location of the mp3 file. I have try to mask the url but then if the user clicks view source, the user would be able to see the location of mp3 file.

Below is the codes that cause the open save dialog box to pop out

[php]

$currentdir = '../mp3';

$filename = "$trackname.mp3";
$pathname = "$currentdir/$filename";

$fr = fopen($pathname, 'r');
$filedata = fread($fr, filesize($pathname));
fclose($fr);

header ( 'Content-Length: ' . filesize ( $pathname ) );
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=$filename");
readfile($pathname);
[/php]

starsunited
Light Poster
44 posts since Dec 2004
Reputation Points: 11
Solved Threads: 1
 

Please use [php] tags next time. I have formatted your post.

Gary King
PHP/vBulletin Guru
Team Colleague
417 posts since Nov 2003
Reputation Points: 53
Solved Threads: 5
 

Your code was missing some quotations as well, so I took the liberty to add them in. You probably just didn't copy and paste the text, right? :)

Gary King
PHP/vBulletin Guru
Team Colleague
417 posts since Nov 2003
Reputation Points: 53
Solved Threads: 5
 

thanks. I have found that this error only occurs in IE. i try in firefox. It's ok

starsunited
Light Poster
44 posts since Dec 2004
Reputation Points: 11
Solved Threads: 1
 

Is this 'Open/Save' dialog box that you are talking about a part of your actual script or is it the download manager associated with the browser?

Gary King
PHP/vBulletin Guru
Team Colleague
417 posts since Nov 2003
Reputation Points: 53
Solved Threads: 5
 

think it's the download manager associated with the browser. it's not part of my script

starsunited
Light Poster
44 posts since Dec 2004
Reputation Points: 11
Solved Threads: 1
 
Your code was missing some quotations as well, so I took the liberty to add them in. You probably just didn't copy and paste the text, right? :)

i did copy n paste though. wat are quotations by the way?

starsunited
Light Poster
44 posts since Dec 2004
Reputation Points: 11
Solved Threads: 1
 
i did copy n paste though. wat are quotations by the way?


Well for [php] $currentdir = '../mp3'; [/php] it used to be [php] $currentdir = '../mp3;[/php]

Gary King
PHP/vBulletin Guru
Team Colleague
417 posts since Nov 2003
Reputation Points: 53
Solved Threads: 5
 

Do you have a link to the live script?

Gary King
PHP/vBulletin Guru
Team Colleague
417 posts since Nov 2003
Reputation Points: 53
Solved Threads: 5
 

you mean the result or wat?

starsunited
Light Poster
44 posts since Dec 2004
Reputation Points: 11
Solved Threads: 1
 
Well for [php] $currentdir = '../mp3'; [/php] it used to be [php] $currentdir = '../mp3;[/php]

oh i @@. oops oh well.... my code no error though else the web will show up blank. think i must have copy wrongly

starsunited
Light Poster
44 posts since Dec 2004
Reputation Points: 11
Solved Threads: 1
 
you mean the result or wat?


I mean, do you have a URL to the website that has the script?

Gary King
PHP/vBulletin Guru
Team Colleague
417 posts since Nov 2003
Reputation Points: 53
Solved Threads: 5
 

yes i have. the script ar? hmm.. u want to take a look at the script?

starsunited
Light Poster
44 posts since Dec 2004
Reputation Points: 11
Solved Threads: 1
 

Can I see it online?

Gary King
PHP/vBulletin Guru
Team Colleague
417 posts since Nov 2003
Reputation Points: 53
Solved Threads: 5
 

cannot see it online though. so what should i do now? also i have this concern that i will violated the company's policy by showing you the script

starsunited
Light Poster
44 posts since Dec 2004
Reputation Points: 11
Solved Threads: 1
 

Hi, i'm facing a similar error. One downloading a.xls using header in php, save works fine, but open gives an error in IE only.
Solutions?

vibhutewary
Newbie Poster
2 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

Hello,
The downloading error was fixed by using caching.
Thanks and Regards,
VT.

Hi, i'm facing a similar error. One downloading a.xls using header in php, save works fine, but open gives an error in IE only. Solutions?
vibhutewary
Newbie Poster
2 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You