...

View Full Version : quick question



mikeisflux
08-05-2012, 01:35 AM
There are two buttons. One has an id=field_photo which needs to stay so that it can connect to the database properly.
The other has an id=photo which the app requires to use properly.
Is there somewhere that I can add something to make photo a pseudonym of field_photo so that one button only can be used?



<dt><label for="field_photo">{lang:"register","select_picture"} <!-- IF settings.require_registration_photo --><i>*</i><!-- ENDIF --></label></dt>
<dd><input id="field_photo" type="file" name="photo" value="" class="text" /></dd>
<p></p>
<p>If on iPhone use button below</p>
<dt><label for="image">Upload Image:</label></dt>
<dd><input type="file" name="photo" id="photo"/></dd>

AndrewGSW
08-05-2012, 01:50 AM
You can't really create a pseudonym, but you might be able to detect if it is an iPhone and hide that button, otherwise hide the other one.


// JavaScript - client-side
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))


// PHP - server-side
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod'))

This way both buttons would still be present to post data, but only one would be displayed to the user.

BTW I don't know why this code I found uses match() and strstr() when they could use indexOf and strpos respectively.

BTWW The same code would work for an iPad, iPuddle, iPoodle, etc..

mikeisflux
08-05-2012, 02:16 AM
that's an awesome piece of coding however it still doesn't fix my database issue. In order for it to post to the database i need the id set to "field_photo" but the app requires id to be "photo" going through and changing this in the database and all the code would be way to extensive.

Thanks all the same though.

AndrewGSW
08-05-2012, 02:33 AM
Not sure if I fully follow, but if the the same file needs to be posted as both 'field_photo' and 'photo' then I don't know if that is possible - particularly client-side.

But 'field_photo' is the id, not the name, so this detail isn't posted anyway.. :confused:. At least, not without the intervention of some JS.

mikeisflux
08-05-2012, 02:49 AM
Not sure if I fully follow, but if the the same file needs to be posted as both 'field_photo' and 'photo' then I don't know if that is possible - particularly client-side.

But 'field_photo' is the id, not the name, so this detail isn't posted anyway.. :confused:. At least, not without the intervention of some JS.

You just gave me an idea. I think that the call in the javascript code is now fixed so I can use just that one button.


<?php
function checkMobileSafari() {
if( preg_match( '/(iPod|iPhone|iPad)/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
return true;
} else {
return false;
}
}
?>
<?php
if( checkMobileSafari() ) {

echo '<div class="info">It\'s Mobile Safari.</div>';

echo '<script type="text/javascript" language="JavaScript" src="/js/prototype.js"></script>
<script type="text/javascript" language="JavaScript" src="/js/picup.js"></script>';

}
?>
<script type="text/javascript">
var currentParams = {}


document.observe('dom:loaded', function(){

$(document.body).addClassName('iphone');

// We'll check the hash when the page loads in-case it was opened in a new page
// due to memory constraints
Picup.checkHash();

// Set some starter params
currentParams = {
'callbackURL' : escape('http://www.datethebasin.com/index.php?m=account_register'),
'referrername' : escape('App Name'),
'referrerfavicon' : escape('http://www.datethebasin.com/favicon.ico'),
'purpose' : escape('Select your photo for the our App.'),
'debug' : 'false',
'returnThumbnailDataURL': 'true',
'thumbnailSize' : '80'
};

Picup.convertFileInput($('field_photo'), currentParams);

});
</script>

The Picup.convertFileInput($(' was set to photo, so i changed it to field_photo. So now it should work right provided the callbackURL is right?

And here is the section of code that is relating to that for the upload button.


<!-- IF settings.enable_registration_photo -->
<dt><label for="field_photo">{lang:"register","select_picture"} <!-- IF settings.require_registration_photo --><i>*</i><!-- ENDIF --></label></dt>
<dd><input id="field_photo" type="file" name="photo" value="" class="text" /></dd>
<!-- ENDIF -->



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum