Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5949781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:17:57+00:00 2026-05-22T17:17:57+00:00

Is it possible upload two different files and archive in zip with new file

  • 0

Is it possible upload two different files and archive in zip with new file name using PHP? following is the form I created.

 <form action="upload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
        <h1>Submit here</h1>

    <p>

    <label for="cat">category</label>

    <select id="cat" name="cat" value="">Category</option>

    <option value="csr2050">Cns</option>

    <option value="npp2023">npp</option>

    </select>

    </p><p>

        <label for="fsheet">fsheet</label>
    <input name="fsheet" type="file" id="fsheet" />
    </p><p>

        <label for="report">Report</label>
    <input name="report" type="file" id="report" />
    </p><p>

    <input type="submit" name="Submit" id="Submit" value="upload" />
    </form>

here what I want is, how to write upload.php that can create a zip archive file of selected two files and rename it to the selected category value then upload it to /upload folder?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:17:58+00:00Added an answer on May 22, 2026 at 5:17 pm

    It is possible and easy too doing in PHP. However there are 3 functionalities you are asking here

    1. Uploading Multiple Files
    2. Zip the files
    3. Rename files

    Each one is different solutions, My code may need to change according to your variables,
    The zip utility link you can see for the details. Also you can get number of posts in Stackoverflow for each of your tasks like, Zip files

    PHP ZIP files on the fly

    Upload multiple files

    Upload two files at once

    Upload

    <?
    
    $file_name1 = $_FILES['fsheet']['name'];
    $file_name1 = stripslashes($file_name1);
    $file_name1 = str_replace("'","",$file_name1);
    $copy = copy($_FILES['fsheet']['tmp_name'],$file_name1);
    
     // prompt if successfully copied
     if($copy){
     echo "$file_name1 | uploaded sucessfully!<br>";
     }else{
     echo "$file_name1 | could not be uploaded!<br>";
     }
    
    
    $file_name2 = $_FILES['report']['name'];
    $file_name2 = stripslashes($file_name2);
    $file_name2 = str_replace("'","",$file_name2);
    $copy = copy($_FILES['report']['tmp_name'],$file_name2);
    
     // prompt if successfully copied
     if($copy){
     echo "$file_name2 | uploaded sucessfully!<br>";
     }else{
     echo "$file_name2 | could not be uploaded!<br>";
     }
    
    ?>
    

    ** Zip **
    First get download the zip utility class from
    http://www.phpclasses.org/browse/file/9524.html

    <?php
        $directoryToZip="secret"; // 
                $outputDir = $_POST['rootfolder'];
                //$outputDir="$folder"; //Replace "/" with the name of the desired output directory.
                $zipName="backup.zip";
    
                include_once("zip/CreateZipFile.inc.php");
                $createZipFile=new CreateZipFile;
                /*
                // Code to Zip a single file
                $createZipFile->addDirectory($outputDir);
                $fileContents=file_get_contents($fileToZip);
                $createZipFile->addFile($fileContents, $outputDir.$fileToZip);
                */
    
                //Code toZip a directory and all its files/subdirectories
                $createZipFile->zipDirectory($directoryToZip,$outputDir);
    
    
                $fd=fopen($zipName, "wb");
                $out=fwrite($fd,$createZipFile->getZippedfile());
                fclose($fd);
                $msg = "Files backup successfully";
                //$createZipFile->forceDownload($zipName);
                $trgtName = date("F-Y-h-i-s"). ".zip";
                copy ($zipName,$outputDir."/".$trgtName);
                @unlink($zipName);
    
    
        ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I upload image files using aspupload component. I was wondering if its possible to
I took this basic upload file script from php.net and it is giving two
Is it possible to upload a file to another server or pass a file
is it possible to upload a file and subsequently when receiving response download the
Is is possible to upload a photo to facebook using Corona?
I can't seem to upload an image using Zend_Service_Nirvanix. Is it even possible? I
On my webpage, I have the following link: <asp:LinkButton ID=lnkChangePic runat=server onclick=lnkChangePic_Click Text=Upload new
Possible Duplicate: How can I know a number of uploaded files with PHP? Hello,
Is it possible to use two different databases on WordPress depending the environment where
I created an simple web interface to allow various users to upload files. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.