Highlighted

multiple file upload controls for uploading to different locations PHP

Community Beginner ,
Apr 22, 2020

Copy link to clipboard

Copied

Hi,

I'm having an issue with inserting data into a table "property" I need to upload a few documents to a document folder on the server in two different locations but I am unsure how to do it with DW.

I have seen some example scripts but they don't seem to do what I need.

 

My form input is:

<input type="file" name="epccert" id="epccert">

And

<input type="file" name="agree1" id="agree1">

They are all named differently.

I'm using the Insert Record server behaviour and not sure where to enter the script to give the upload locations.

The scripts I have seen would need to be added over 10 times for each of my elements which seems a little silly.

Is there an easy way to do this?

 

Thanks in advance

Views

308

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

multiple file upload controls for uploading to different locations PHP

Community Beginner ,
Apr 22, 2020

Copy link to clipboard

Copied

Hi,

I'm having an issue with inserting data into a table "property" I need to upload a few documents to a document folder on the server in two different locations but I am unsure how to do it with DW.

I have seen some example scripts but they don't seem to do what I need.

 

My form input is:

<input type="file" name="epccert" id="epccert">

And

<input type="file" name="agree1" id="agree1">

They are all named differently.

I'm using the Insert Record server behaviour and not sure where to enter the script to give the upload locations.

The scripts I have seen would need to be added over 10 times for each of my elements which seems a little silly.

Is there an easy way to do this?

 

Thanks in advance

Views

309

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 22, 2020 0
LEGEND ,
Apr 22, 2020

Copy link to clipboard

Copied

See if the below helps:

https://makitweb.com/multiple-files-upload-at-once-with-php/

 

Edited. The above will give you a basic upload however if you want to upload the files to 2 different folders on the server then alter the php script as below:

 

<?php
if(isset($_POST['submit'])){

// Count total files
$countfiles = count($_FILES['file']['name']);

 

// Looping all files

for($i=0;$i<$countfiles;$i++){
$filename = $_FILES['file']['name'][$i];
$folder_1 = 'uploads_1/' . $filename;
$folder_2 = 'uploads_2/' . $filename;

// Upload file
move_uploaded_file($_FILES['file']['tmp_name'][$i], $folder_1);
copy($folder_1, $folder_2);
}

}
?>

 

 

Of course this is as basic as it gets. You'd probably want to do a check as to which file extensions are allowed to be uploaded, max-size allowed etc.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 22, 2020 3
Community Beginner ,
Apr 22, 2020

Copy link to clipboard

Copied

Thank you so much for taking the time to reply to my post.

I will try this now.

Thanks again!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 22, 2020 0