LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Cannot not run executable jar file after set content type for download (https://www.linuxquestions.org/questions/programming-9/cannot-not-run-executable-jar-file-after-set-content-type-for-download-261950/)

antony_csf 12-02-2004 08:14 PM

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!!
:confused: :confused: :confused:

antony_csf 12-08-2004 12:22 AM

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;
?>


All times are GMT -5. The time now is 03:06 AM.