LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-02-2004, 08:14 PM   #1
antony_csf
Member
 
Registered: Jun 2004
Posts: 51

Rep: Reputation: 15
Unhappy Content type for download


Dear all,

I have a jar file in server. I download it through ftp. And then I run the command : java -jar Hello.jar
The output is ok.

Then I try to make a download page (php) for user to download the executable jar file. However, after I download it. I run the same command. The output generate the following error :
================================================
Code:
Exception in thread "main" java.util.zip.ZipException: error in opening zip file

        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)
================================================

The download.php content
================================================
PHP Code:
    header("Cache-Control: ");// leave blank to avoid IE errors
    
header("Pragma: ");// leave blank to avoid IE errors
//    header("Content-type: application/octet-stream");
    
header("Content-type: application/java-archive");
    
header("Content-Disposition: attachment; filename=\"".$fileName."\"");
    
header("Content-Disposition: inline; filename=$fileName");
    
header("Content-Transfer-Encoding: binary");                                        
    
header("Content-length:".(string)(filesize($fileString)));
    
sleep(1);
    
fpassthru($fdl);
    
header ("Connection: close"); 
================================================

so I guess the download.php cause the jar file error. but I cannot find the error. Would anyone know the solution?

Any person familiar with header.

thx help!!

Last edited by antony_csf; 12-03-2004 at 04:15 AM.
 
Old 12-08-2004, 12:22 AM   #2
antony_csf
Member
 
Registered: Jun 2004
Posts: 51

Original Poster
Rep: Reputation: 15
I fix the problem with using the exit at the end of php.
if no exit the the file size will difference !!

hope can help people to fix problem !!!

http://halfos.street-tv.net/lib/php/...ssthru.php.htm

<?php
$name = "foobar.gif";
header("Content-Type: image/gif");
header("Content-Length: ".filesize($name));
fpassthru($name);
exit;
?>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run a java jar file. sabliny Programming 7 11-05-2005 01:59 PM
Download ,run file type wazntme Linux - Newbie 1 10-27-2005 11:57 AM
how to run a jar file in redhat9.0 balanagireddy Linux - Newbie 10 06-07-2004 06:12 AM
Using Tomcat to run a .jar file davee Linux - Software 1 08-15-2003 05:47 AM
set content-type to 'text/html' in sendmail, using perl script brokenfeet Programming 3 08-05-2003 02:12 PM


All times are GMT -5. The time now is 09:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration