Jump to content

Adding another field in the same form


narjis

Recommended Posts

Hi,

I want to add another file on the same form if a user wants to upload more than one files to his directory.

Can anybody suggest how to do it.

Thanx.

<?php 
[color=red]if($_POST['Submit'])header("Location: zipCreate.php")
elseif($_POST['addFile']){
echo "";[/color]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="form2" id="form2">
  <div align="center" style="background-color:#006666; font-weight:bold; color:#33FF99;">CREATING ZIP FILE</div>
  <p>Choose a File to add to zip
    <input type="file" name="file" />
    <input name="addFile" type="submit" id="addFile" style="background-color:#006666; border: 1px; color: #33FF99; font-family: 'Times New Roman', Times, serif; font-weight: bold; font-size: 16px;" value="Add File"  align="absmiddle" />
  </p>
  <p>
    <input  align="absmiddle" style="background-color:#006666; border: 1px; color: #33FF99; font-family: 'Times New Roman', Times, serif; font-weight: bold; font-size: 16px;"type="submit" name="Submit" value="Upload File" />
  </p>
</form>
</body>
</html>

I am having two submit buttons one is for adding more files and another one is for Uploading the files.

Then I want to make a zip file of all the uploaded files and save it on the server.

Link to comment
Share on other sites

There are many scripts and tutorials on the internet for handling multiple file uploads on the front end/client side. This is usually handled via javascript or some other sort of client side language unless you simply want to add a static amount of upload boxes. A quick google search will aid you in this part of it.

 

 

As far as the PHP, read here: http://php.net/manual/en/features.file-upload.multiple.php

 

that details how you handle multiple file uploads on the php side.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.