Upload photos from Phone Gallery to a server

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]);
     }
   }
}
?>
Leave a comment

5 Comments.

  1. Can you make it possible that it not only uploads images, but entire forms that may include images? That way we can not only submit images to a site but something like a blogpost, or an image board post that includes an image.

    • Hi,

      The methodology prescribed is only to allow upload of photos. You can specify a text area where the html content can be copy pasted and submitted. But not sure if that is what you are looking for.

      Regards

      sapnagroup

  2. Can you make it work for ipad as well? I tried but the upload button doesnt work, i do get the aurigma app and can choose from all the pictures that are stores on the ipad… Would be so great, also for printing (not on your own printer but from a developercompany, making books, cards etcetera.) these pictures…. Is a serious missing functionality for a device that can store and adjust pictures so easy….

    • Hi Ariane,

      We were not aware it doesn’t work on Ipad. Thanks for pointing it out. We will check it out and get back to you. It may take a few days for us to correct it.

      Regards

      sapnagroup

  3. How do you mean it’s free the license costs $199 :sad: :evil: :sad:

Leave a Reply

Your email address will not be published. Required fields are marked *

*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>