Link to home
Start Free TrialLog in
Avatar of Champ007
Champ007

asked on

Upload Image file radio button option

Hello All,

I have an upload field in a form that allows the user to upload a photo. If the user does not have a photo, I'd like them to be able to select an image, located on mySite by clicking a radio button.

Basically what I want it to do is to give the user the option to select an image (on the mySite server) by clicking one of the radio buttons, if they don't have an image (file) to upload.

The function I am looking for is to load the URL (i.e. http://mySite.com/images/corp-man1.jpg) into the  "photo_img"  field when the user selects one of the radio buttons.

The upload code itself works fine. I've added radio buttons. I just need a way to substitute the "photo_img" value using the radio buttons.

Here's a code snippet. I'm assuming there will be some sort of 'IF' statement and variables.

Thank you for taking a look at this.
<p><label for="photo_img">Upload Photo:</label><br/>
	<input type="file" name="photo_img" id="photo_img">
	<input type="submit" value="Clear" onclick="javascript: clearFileInputField('photo_img'); return false;"/>
</p><br />

	<table width="200" border="0" cellpadding="0" cellspacing="0">
				<tr>
							<td width="110" align="center" valign="middle" bgcolor="#FFFFFF"><label>
										<input type="radio" name="PhotoSubM" value="http://mySite.com/images/corp-man1.jpg" id="PhotoSubM_0" />
										Man1</label></td>
				</tr>
				<tr>
							<td align="center" valign="middle" bgcolor="#FFFFFF"><label>
										<input type="radio" name="PhotoSubM" value="http://mySite.com/images/corp-man2.jpg" id="PhotoSubM_1" />
										Man2</label></td>
				</tr>
				<tr>
							<td align="center" valign="middle" bgcolor="#FFFFFF"><label>
										<input type="radio" name="PhotoSubM" value="http://mySite.com/images/corp-man3.jpg" id="PhotoSubM_2" />
										Man3</label></td>
				</tr>
				<tr>
							<td align="center" valign="middle" bgcolor="#FFFFFF"><label>
										<input type="radio" name="PhotoSubM" value="http://mySite.com/images/corp-man4.jpg" id="PhotoSubM_3" />
										Man4</label></td>
				</tr>
				<tr>
							<td align="center" valign="middle" bgcolor="#FFFFFF"><label>
										<input type="radio" name="PhotoSubM" value="http://mySite.com/images/corp-man5.jpg" id="PhotoSubM_4" />
										Man5</label></td>
				</tr>
	</table>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of cyberstalker
cyberstalker

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you do not have experience programming in PHP, you might find that this book is helpful.
http://www.sitepoint.com/books/phpmysql4/

In order to give you any concrete help with this question we will need to see all of the HTML form script and all of the PHP action script.  Please post those in the code snipppet so we can see what you have tried already.  Once we have that, we will be able to suggest solutions that are more on target than just a teaching example.  Thanks.
Avatar of Champ007
Champ007

ASKER

cyberstalker - If PHP is the only way to go, can you provide a link or 2 that will provide a teaching example that I can follow.

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I submitted a delete request for question: https://www.experts-exchange.com/questions/26817561/Image-upload.html.
There is a pending objection to deleting this topic. This post is the open question I am seeking a solution. Currently there are no satifactory solutions. An author's comment  to cyberstalker is pending a reply.
"Currently there are no satifactory [sic] solutions."

You will need to work with us a little bit here (and you may find that you need to hire a professional developer, if you do not have the knowledge, skills and abilities to write code).  The strategy you will want to use goes something like this.

In the action script that processes the form input, you will look for the $_FILES array to see if an image was uploaded.  You will test the "error" indicators, and if there are no errors and a valid file was present, you will use that image.  If that is not the case, then you will look in the $_POST array to see if a radio button named $_POST["PhotoSubM"] is set.  You will want to be very careful about using the value in this field, since you're going to be transmitting a URL in the field.  Nice people will not tamper with the URL.  Hackers will have a field day destroying your site and attacking all the browsers of visitors that come to your site if you do not sanitize this input.

Please post the entire HTML form script and PHP action script as you have them now, thanks.  Partial scripts are not really useful in this case.
No solution provided.
An exact and detailed explanation of the solution was provided three weeks ago at ID:34910806, yet you gave a bad grade.  I do not understand.

Why did you refuse repeated requests to post your code?  Why did you mark the response down to a "B"?  Can you think of any reason we would want to try to help you in the future?  If so, please post those reasons.  Thanks, ~Ray