Jump to content

culhy

New Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by culhy

  1. SOLVED: I rechecked system (like 200 files) and found one that was saved with BOM so there were 1 empty line. that doesnt matter in php or pdf files but its fatal in all others thx for advice. this is sufficient for downloading: $a = mysql_fetch_assoc($q); header( 'Content-Description: File Transfer'); header( 'Content-Type: '.$a["type"]); header( 'Content-Disposition: attachment; filename='.$a["name"]); echo base64_decode($a["data"]);
  2. btw file fata r good. most important for me is attaching files to email and it works (like this): $mail->AddStringAttachment( base64_decode($a['data']), $a['nazev'], 'base64', $a['typ'] ); files from email r correct so problem is definitly somwhere here
  3. ok, i made adjustments and it dont work. using readfile() causes that no filetype works. and if i use header( 'Content-Length: ' . filesize($a['length'])); same result. here is my full scrpt, it works for pdf and php files, dont work for any image or rar etc if(isset($_GET["id"])){ $id = $_GET["id"]; $q = db_q("SELECT `data`, `nazev`, `typ`, length(`data`) as length FROM `mailing_files` WHERE `soubor_id` = '$id'", "databaze-kontaktucom_dataserver"); } else if(isset($_GET["nazev"])){ $nazev = $_GET["nazev"]; $q = db_q("SELECT `data`, `nazev`, `typ`, length(`data`) as length FROM `mailing_files` WHERE `nazev` = '$nazev'", "databaze-kontaktucom_dataserver"); } if(mysql_num_rows($q) == 1){ $a = mysql_fetch_assoc($q); header( 'Content-Description: File Transfer'); // no effect but dont causes error header( 'Content-Type: '.$a["typ"]); //header('Content-Type: application/octet-stream'); // no effect header( 'Content-Disposition: attachment; filename='.$a["nazev"]); //header( 'Content-Length: ' . filesize($a['length'])); // causes error //header('Pragma: public'); // no effect //header('Expires: 0'); // no effect //header('Content-Transfer-Encoding: binary'); // no effect //header('Content-Transfer-Encoding: base64'); // no effect //ob_clean(); // no effect //flush(); // no effect //readfile($a['data']); // causes error echo base64_decode($a["data"]); // works best so far //echo $a["data"]; // just print } exit;
  4. Hi, i have problem on my site. Im trying to make simple file manager. Uploading script looks like: $data = file_get_contents($_FILES["file"]["tmp_name"]); $data = base64_encode($data); $type = $_FILES["file"]["type"]; $name= $_FILES["file"]["name"]; ... INSERT INTO .... On the other side is output script: ...SELECT... $a = mysql_fetch_assoc($q); header( 'Content-Type: '.$a["type"]); header( 'Content-Disposition: attachment; filename='.$a["name"]); echo base64_decode($a["data"]); exit; I can actualy download .pdf or .php but i cant download .jpg, .rar, .docx etc I tryed like bilion ways how to edit output script, this is simplest version i have so far. All files r in utf8 w/o BOM. I allready used modifications like: header('Content-Transfer-Encoding: base64'); echo $a["data"]; didnt worked... i know that data in db r correct, this actualy work: <img alt="<?php echo $a["name"]; ?>" src="data:image/jpeg;base64,<?php echo $a["data"]; ?>" /> So, why some files cant be downloaded this way?
×
×
  • 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.