Jump to content

PHP Form Help


andymike07

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

Archived

This topic is now archived and is closed to further replies.

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