Jump to content

Recommended Posts

I'm writing a script that allows user's to upload an unknown number of files to the server. I've set the form up so it has one file upload field, named file1, by default. If the user wants has another file to upload they simply click an "Add Upload Field." link that uses javascript to add another file upload field. Each new field the user adds is named "file2", "file3", "file4", etc... Is there an easy way to use PHP to find the data for the fields added with Javascript so I can access them with my script?

Link to comment
https://forums.phpfreaks.com/topic/83165-php-form-help/
Share on other sites

yes change your upload adding scheme naming from

<input type="file" name="file1" />

<input type="file" name="file2" />

<input type="file" name="file3" />

 

etc

to

<input type="file" name="file[1]" />

<input type="file" name="file[2]" />

etc.

 

Then say

<?php
foreach($_FILES['file'] as $key => $value){
//Handle uploads
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/83165-php-form-help/#findComment-423025
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.