Apple iPad/iPhone
Ipad doesn’t allow a web based app to access photos direclty. We have found an interesting way to go about accessing the photos on the Ipad and uploading them via the browser. Using “Aurigma Up” – a photo upload App for iOS devices, users can upload images from the device to your site.
To see it in action, you can do the following as detailed below.
1. Download “Aurigma Up” from App Store. This is a free app and you will only need an Apple account to download it.
2. After the native app is downloaded and ready to use, open in safari browser http://www.sapnagroup.com/mob/BasicDemo/test.html
3. Click on the link to upload images, this will open up the native app. You can select multiple images from Phone Gallery or click new ones using the camera and then upload.
5. After uploading you will be redirected to a gallery page showing the images uploaded.
6. Please note that when new files are uploaded all previously uploaded photos are deleted.
Let’s see now how to do it
1. Insert the upload link on the page
Inside the <BODY> tag add the following
<a href="aurup:?uploadUrl=http://yoursitename.com/upload.php&redirectUrl=http://yoursitename.com/gallery.php"> Upload Images </a>
uploadUrl – the target page to which Aurigma Up sends the photos. We will explain below how to create such page
redirectUrl – the page to which Aurigma Up will bring the user back when the upload completes. It can be the same page or the photo gallery page.
licenseKey – more on this in the next step.
2. Get license key
Register at http://www.aurigma.com/MyAurigma/Register.aspx and get license key for your domain for free!
3. Saving the uploaded photos on your server hard drive
You need to create a simple server-side script, and specify its URL in the uploadUrl attribute as described above. This script will accept the POST request sent by Aurigma Up.
The following snippet of code handles uploads
PHP code example:
<?php
$path = realpath('./Temp/') . DIRECTORY_SEPARATOR;
$fileCount = $_POST["PackageFileCount"];
for ($i = 0; $i < $fileCount; $i++) {
if (isset($_FILES['File0_' . $i])) {
move_uploaded_file($_FILES['File0_' . $i]['tmp_name'], $path . $_POST['SourceName_' . $i]);
}
}
?>
Android
Android browser now supports File Upload. To achieve this you can use the <input type=”file” /> element. When you click “Choose File” you will get a popup menu with options to: select a file from the Gallery, from the music collection or from the sound recorder.
This is how you can achieve it in 2 simple steps.
1. Insert the upload button on the page
Inside the <BODY> tag, add the following
<form name="fileupload" method="post" target="targetfile.php" enctype="multipart/form-data" > <input type='file' name="upload" > <input type="submit" value="Send"> </form>
2. Saving the uploaded photos on your server hard drive
PHP code example:
<?php
$target_path = "/path/to/store/file/"; // replace this with the path you are going to save the file to
if(is_array($_FILES)) {
foreach($_FILES as $fileKey => $fileVal){
if($fileVal[name]) {
move_uploaded_file($_FILES["upload"]["tmp_name"],$target_path.$fileVal[name]);
}
}
}
?>