Current location: Hot Scripts Forums » Programming Languages » PHP » Multiple field, file upload form


Multiple field, file upload form

Reply
  #1 (permalink)  
Old 07-11-05, 12:21 PM
berlamont berlamont is offline
New Member
 
Join Date: Jun 2005
Location: michigan
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Multiple field, file upload form

I have a perfectly working upload form at the moment, but I am having a hard time figureing out how to add the ability to generate other fields to submit along with the upload. Has anyone ever made a file upload form that submits other information such as the authors name (i'm uploading documents). Would it be hard to have a table generate from a form like that after a file was uploaded? I'm thinking I could store both the author and file in an mysql database, but would I have to separate that from the actual upload script?

Heres what I have so far:

PHP Code:

<?php 

  $numfile 
20
  
$servdir  "my file dir"
  if (
$_POST
 { 
    for (
$i=0;$i<$numfile;$i++) 
    { 
      if (
trim($_FILES['myfiles']['name'][$i])!=""
      { 
        
$newfile $servdir.$_FILES['myfiles']['name'][$i]; 
        
move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile); 
        
$x++; 
      } 
    } 
 } 
  if (isset(
$x)&&$x>0) print "All went well.<br>"
  print 
"<form method='post' enctype='multipart/form-data'>"
  for(
$i=0;$i<$numfile;$i++) 
  { 
    print 
"<input type='file' name='myfiles[]' size='30'><br>"
  } 
  print 
"<input type='submit' name='action' value='Upload'>"
  print 
"</form>"
?>

Last edited by berlamont; 07-11-05 at 12:24 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-11-05, 05:57 PM
dennispopel dennispopel is offline
Coding Addict
 
Join Date: Mar 2005
Posts: 263
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,

Just create additional fields in the form in the loop where you create the upload fields and name them like author[], date[] etc. You will then access them just like the $_FILES array, but using the $_POST array.
__________________
onPHP5.com - PHP5: Articles, News, Tutorials, Interviews, Software and more
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
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
ASP upload prob minority ASP 1 06-27-05 09:35 AM
Multiple form fields saved in one mysql field?? cebuy PHP 4 10-15-04 01:08 PM
formmail problem gscraper Perl 12 08-27-04 04:06 AM
transfer multiple value of a form field to another field ore JavaScript 2 06-18-04 09:50 PM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 11:15 AM


All times are GMT -5. The time now is 03:41 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.