Jump to content

Correct Headers


Onetoomanysodas

Recommended Posts

I am trying to have a script forward a java class to the client but the applet is failing to load.

 

The file acts as it should when I navigate to the script with these headers:

 

header('Content-type: class/java');
header('Content-disposition: attachment; filename="applet.class"');
header('Content-length: ' . filesize($path));

print($file);

 

The problem is that the applet object is failing from the html document so it must be an issue with lack of proper headers. I need to convince firefox that the request being returned is an actual class file.

Link to comment
https://forums.phpfreaks.com/topic/119903-correct-headers/
Share on other sites

I'm not quite sure what you mean, do the posted headers work or are they the ones you are using now?

I do not know very much about java but the headers you posted would do what are in the comments

header('Content-type: class/java'); //says that this page is a java class
header('Content-disposition: attachment; filename="applet.class"'); //says that you want the browser to download the class to the disk
header('Content-length: ' . filesize($path));

print($file); //the class is read and put on the screen?

if you want to just have the browser parse it as a class then the following should be good

<?php
header('Content-type: class/java');
print($file);
?>

or if you want the client to download it:

<?php
header('Content-disposition: attachment; filename="applet.class"');
?>

Once again I'm pulling from my limited Java knowledge so I may be wrong.

Link to comment
https://forums.phpfreaks.com/topic/119903-correct-headers/#findComment-617783
Share on other sites

Yes thankyou but I know what my headers are doing. It's actually better to use:

 

`Content-Type: application/octet-stream`

 

for better compatibility with the applet object in the DOM but for some reason it's still not loading it and I was just wondering if anyone knows this issue?

Link to comment
https://forums.phpfreaks.com/topic/119903-correct-headers/#findComment-618342
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.