| | |
open save dialog box error
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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]
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]
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?
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?
•
•
•
•
Originally Posted by Gary
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?
•
•
•
•
Originally Posted by starsunited
i did copy n paste though. wat are quotations by the way?
![]() |
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: Selecting only one day from week
- Next Thread: about time??
| Thread Tools | Search this Thread |
apache api array basic binary body broken cakephp class cms code computing confirm cron curl customizableitems database date date/time delete dynamic ebooks email error file filter folder form forms forum function functions gc_maxlifetime header headmethod href htaccess html iframe image include ip javascript joomla limit link list login malfunction mediawiki memmory memory menu msqli_multi_query multiple mycodeisbad mysql navigation number oop parameter parsing paypal pdf php phpincludeissue query question random recourse regex script search seo server sessions snippet source sp space speed sql static subdomain system table tag thesishelp trouble tutorial update upload url variable vbulletin web webdesign white xml youtube





