The below code works absolutely fine when i run on my local computer. However, i am building a mobile app using HTML5, CSS3, JAVASCRIPT,jquery-mobile using the cordova phonegap plugin.
If you look at the form element below i have an action attribute that calls a php file located on a web server. This will be impossible to call if i am building a mobile app right because they are located on different servers ? . In this case i cannot make an ajax call because i am transferring an image because you can't upload files using Ajax.?
How do i send an image from my mobile application the the php file on the web server then ?
1) index.html (Will build a Phone Gap app an distribute to users )
<form action="php/updateProfilePicture.php" method="post" data-ajax="false" enctype="multipart/form-data">
<label for="file">Update Profile Picture:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
2) updateProfilePicture.php (on the web server)
<?php
$con = mysqli_connect("localhost", "root", "root123", "xyz", "3306");
mysqli_select_db($con, "xyz");
$email = 'xyz@gmail.com';
$stmt = $con->prepare('UPDATE profileinformation SET Image = ? Where email = ? ');
$null = null;
$stmt->bind_param('bs',$null, $email);
$stmt->send_long_data(0, file_get_contents($_FILES['file']['tmp_name']));
$stmt->execute();
if ($stmt->errno) {
echo "FAILURE!!! " . $stmt->error;
}
$stmt->close();
?>