Page 1 of 1

Saving a file to my server

Posted: Sun May 03, 2009 4:45 pm
by Anarking
Hi there


I currently have this code that takes a file from a SQL database and lets you download. I want o create a zip file with many files in it so I need to save these files to a server.

How do I do this?


Currently I have this code

Code: Select all

 
<?php
mysql_connect("localhost","root","");
mysql_select_db("test");
$query = "SELECT data,filename,filetype FROM uploads where id=$id";
$result = MYSQL_QUERY($query);
$data = MYSQL_RESULT($result,0,"data");
$type = MYSQL_RESULT($result,0,"filetype");
$name = MYSQL_RESULT($result,0,"filename");
$names = str_replace(' ', '_', $name);
Header( "Content-type: $type");
Header("Content-Disposition: attachment; filename=$names");
print $data;
//echo $name;
?> 
 

Re: Saving a file to my server

Posted: Sun May 03, 2009 6:31 pm
by it2051229
As long as you know how to read and use classes that's not a problem.. you can visit http://www.phpclasses.org and they provide ready made classes that you need. Regarding your problem, you can search in there the Class for Zipping or compressing files and folders which I have seen and been using for quite some time. There are a lot of versions of those and you just pick the one that suits you or you understand the most.