|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
problem downloading JPEG image
Oki i have a problem that after downloading JPEG image through my download script the Adobe Photoshop can open it and says: "Could not open the document because a JPEG marker segment length is too short (the file
may be truncated or incomplete)."? What can be wrong? Script is like that! NB! the downloading is working great except that the JPEG image is rotten!! <?php //////////////////////////////////////////////////////////////////// //SKRIPTI:download 1.1, // //e-mail:mrq@themail.com // //Greated: 04.04.2002 // // // //////////////////////////////////////////////////////////////////// require("incl/register.php"); if($HTTP_REFERER=="http://www.mfa.ee:83/gallery//download.php"){ echo"First you have to register and then download!"; exit; } if(isset($id)){ require"incl/mysql.php"; $select = "SELECT klient_pildid.pildi_id,pildid.pilt,pildid.pealkiri ,pildid.valja FROM pildid,klient_pildid WHERE pildid.id=$id AND klient_pildid.klient_id='$HTTP_GET_VARS[k]'"; $valjasta = mysql_query($select) or die("Lause on vigane"); while(list($id,$pilt,$pealkiri,$valja) = mysql_fetch_row($valjasta)){ echo $id; echo"<br>"; if($valja==1){ $fileDir="temp2434"; $completeFilePath=$fileDir.'/'.$pilt; if(strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'MSIE')){ // IE cannot download from sessions without a cache header('Cache-Control: public'); }else{ //header("Cache-Control: no-cache, must-revalidate"); header("Cache-Control: no-cache"); } header("Pragma: no-cache"); header("Content-Type: image/jpegn"); header ("Connection: close"); header("Content-Disposition: attachment; filename="$pealkiri"n"); header("Content-Transfer-Encoding: binaryn"); header("Content-length: ".(string)(filesize($completeFilePath))); $fd=fopen("$completeFilePath","rb"); fpassthru($fd); exit; }else{ Header("location:$HTTP_REFERER"); } } mysql_close(); } ?> |
|
#2
|
|||
|
|||
|
RE: problem downloading JPEG image
Try using:
while(!feof($fd)) { print fread($fd, 4096); } fclose($fd); in place for the fpassthru.. |
|
#3
|
|||
|
|||
|
RE: problem downloading JPEG image
nop did'nt work either!
Mb something else. If some1 could test this script or something like that then look does the jpeg image remain the same or again will be rotten then i know that the error is not only me or counterwise! |
|
#4
|
|||||
|
|||||
|
RE: problem downloading JPEG image
php Code:
I used that script to test, which is basically your script without the database parts and it works! So maybe something you are pulling from the database is wrong? Try running the above script with a test.jpg file in the same dir and see if it works right... |
|
#5
|
|||||
|
|||||
|
RE: problem downloading JPEG image
Oki i got it working
Thx to Matt The code is below php Code:
|
|
#6
|
|||
|
|||
|
RE: problem downloading JPEG image
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > problem downloading JPEG image |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|