Jump to content

Form Submission


SH1989

Recommended Posts

Hi All,

I am trying to submit multiple form fields, whereby I am asking users to supply specific files. I can get it to upload a single file correctly, however when I increase this to 2 or 3, it's using the same file for all of them. I have used print_r($_FILES) to check everything with the files seems to be OK, and it all looks OK. I need to be able to pair the files, so that's why I haven't used the multiple option.

I have tried changing the variables so they are completely different, but I am at a total loss right now.
 

## First Document
if(!empty($_FILES["dc1"])){ 
	$fileName1 = htmlspecialchars_decode((basename($_FILES["dc1"]["name"]))); 
	$fileTypeA1 = pathinfo($fileName1, PATHINFO_EXTENSION); 
    $targetFilePath1 = $uploadDir . $uID . '-' . $randnum . '.' .$fileTypeA1; 
 	
	if(move_uploaded_file($_FILES["dc1"]["tmp_name"], $targetFilePath1)){ 
		$uploadedFile1 = $targetFilePath1; 
		}
	} 

## Second Document
if(!empty($_FILES["dc2"])){ 
	$fileName2 = htmlspecialchars_decode((basename($_FILES["dc2"]["name"]))); 
	$fileTypeA2 = pathinfo($fileName2, PATHINFO_EXTENSION); 
    $targetFilePath2 = $uploadDir . $uID . '-' . $randnum . '.' .$fileTypeA2; 
    
	if(move_uploaded_file($_FILES["dc2"]["tmp_name"], $targetFilePath2)){ 
    	$uploadedFile2 = $targetFilePath2; 
     }
	} 

 

Edited by SH1989
Clean code up
Link to comment
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.