Current location: Hot Scripts Forums » Programming Languages » PHP » How to prepopulate file input box?


How to prepopulate file input box?

Reply
  #1 (permalink)  
Old 06-09-04, 02:22 AM
cgott42 cgott42 is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
How to prepopulate file input box?

I'm taking a different approach to a question I posted recently.
Now, I would like to know how to prepopulate the file input boxes for the user

Below is the code that I have:
It sets up 4 input boxes. I would like to populate all 4 boxes with:
c:\cdrombb\export\test1.txt
c:\cdrombb\export\test2.txt
c:\cdrombb\export\test3.txt
c:\cdrombb\export\test4.txt

when the user hits submit, it uploads all 4 files.

Any ideas on how to do this?

file: upload.php
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" enctype="multipart/form-data" method="post" action ="processFiles.php">
<p>

<?
// start of dynamic form
$uploadNeed=4;
for($x=0;$x<$uploadNeed;$x++){
?>
<input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">

</p>
<?
// end of for loop
}
$uploadFile1_name = 'c:\CDROMBB\EXPORT\TEST2.txt';
?>
<p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>


file: processFiles.php
<?
$uploadNeed = $_POST['uploadNeed'];
// start for loop
for($x=0;$x<$uploadNeed;$x++){
$file_name = $_FILES['uploadFile'. $x]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$copy = copy($_FILES['uploadFile'. $x]['tmp_name'],$file_name);
// check if successfully copied
if($copy){
echo "$file_name | uploaded sucessfully!<br>";
}else{
echo "$file_name | could not be uploaded!<br>";
}
} // end of loop
?>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with my largest perl script. Grabbing data from a file. Sunnmann Perl 2 04-23-08 03:27 AM
File input daveyisu Windows .NET Programming 1 03-25-04 04:08 PM
Getting the created file (fopen/fwrite) Programme PHP 5 02-14-04 03:09 PM
Please I Need help before all my hair is gone! LisatheNovice Perl 6 11-22-03 03:05 PM
Upload file type and size limiter! Arctic ASP 1 08-02-03 07:06 PM


All times are GMT -5. The time now is 10:38 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.