Unstoppable Domains

Making a file hosting script. HELP!

Spaceship Spaceship
Watch

scousescott2k5

Established Member
Impact
0
Hi guys. I'm trying to make a file upload script.

It does work to a certain degree. A user uploads a file and it stores in a folder called /uploads/

I need the script to then convert the uploaded file to a .zip and then give the user the download url.

If you could tell me where I'm going wrong and give me the correct code, I will be very, very grateful!

Here is the error I'm getting now:

Fatal error: Class 'ZipArchive' not found in /home/fileflam/public_html/uploader.php on line 29

The website is www.fileflamingo.com

Thanks!

PHP:
    <?PHP

$target_path = "uploads/";


$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
$_FILES['uploadedfile']['tmp_name'];  

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

      // Create the md5 hash for naming purposes;

      $zipname = md5($somename_probably_user_provided);

       
 
      // create object
  
      $zip = new ZipArchive();
  
       
   
      // open archive
   
      if ($zip->open($zipname, ZIPARCHIVE::CREATE) !== TRUE) {

          die ("Could not open archive");

      }
 

      // list of files to add

      // list of files to add

      $fileList = array(
  
          'fstab2.php',
 
          'images/branch.gif',
 
          'files/php1.php'

      );
       

      // add files
     foreach ($fileList as $f) {

          $zip->addFile($f) or die ("ERROR: Could not add file: $f");   

      }
  
         
  
      // close and save archive
  
      $zip->close();
 
      echo "Archive created successfully.";   
 
      ?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
0
•••
Thanks for your reply... The server is mine, but I'm having trouble checking/installing ZipArchive.

I'm no good with PHP, could you tell me how to install it on my WHM?
 
0
•••
Do you run PHP 4 or 5?
 
0
•••
5.2.4
 
0
•••
Then PHP needs to be compiled with --enable-zip.
 
0
•••
Swoosh... that went way over my head lol. Could you tell me how to do that please? Sorry to be a pain!
 
0
•••
0
•••
Thanks, can't do it lol but thanks anyway.
 
0
•••
If you have cPanel you can do it automatically under WHM, configure and rebuild apache section. If you do not have a control panel like that, you must download the source from php and compile it yourself manually.

By the way, what is the purpose of converting them to zips. Its not the best user friendly practice.
 
0
•••
Hi thanks guys, I solved the problem it wasn't because PHPzip wasn't installed it was just my soppy coding. Check out www.fileflamingo.com for the finnished result.

Scott.
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back