Jump to content

Is there a way to determine which file input prompt was used?


kadin

Recommended Posts

 

I can determine which radio button is selected for each file upload prompt because I have a name and a value. So the array name=image can have one of three values for each file upload prompt.

 

Is there a way to determine which of the three file upload prompts was loaded (clicking browse & select image) with an image and which was not? There doesn't seem to be a value like there is with radio buttons. I want to be able to replace an already uploaded image with another.

 

Thanks.

 

<input type='radio' name='image[image0]' value='keep' checked='checked'/>

<input type='radio' name='image[image0]' value='delete' />

<input type='radio' name='image[image0]' value='replace' />

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

 

<input type='radio' name='image[image1]' value='keep' checked='checked'/>

<input type='radio' name='image[image1]' value='delete' />

<input type='radio' name='image[image1]' value='replace' />

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

 

<input type='radio' name='image[image2]' value='keep' checked='checked'/>

<input type='radio' name='image[image2]' value='delete' />

<input type='radio' name='image[image2]' value='replace' />

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

 

if (isset($_POST['submitted']) && 
	($image = $_POST['image'])) {

	foreach($image as $imageKey => $imageValue) {
		if ($imageValue == 'keep') {
			do this	
		}
	}	
}

 

 

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.