[FX.php List] upload images from iphone to supercontainer
david weiner
1265 at lucerneblvd.org
Fri Feb 11 19:32:21 MST 2011
Hi,
I've got a situation where I am able to go from a php page to an iphone app, pick a photo to upload, send it back to a php file on the webserver and then grab the file and upload it to supercontainer.
The relevant files are the images-results.php page which does a search and I use some of the returned data to populate the javascript variable called "context" so I know where to upload the image later and the upload-to-supercontainer.php file where the image gets returned from the iphone app and is then uploaded to my supercontainer server.
the iphone app is called quickpic, and the documentation is here:
http://www.cliqcliq.com/support/quickpic/#web-app-integration
As you can see I have resorted to hardcoding the filename quickpic.jpg because that's how it comes back from the app and it is apparently not accessible through the $_FILES array since that always comes back empty in safari mobile.
I have written the developer a few times but I guess my questions are beyond what they consider necessary support and they've stopped answering my emails.
What I would like to know is if any of you could think of a better way to go about this.
Thanks,
David
+_+_+_+_+_+_+_+_+_+_+_+
Here's the relevant part of images-results.php:
<script type="text/javascript">
window.launchQuickpic = function() {
var start = new Date();
setTimeout(function() {
if (new Date() - start > 2000) {
return;
}
window.location = 'http://www.cliqcliq.com/quickpic/install/';
}, 1000);
var getParams = ['action=http://localhost/upload-to-supercontainer.php',
'continue=http://localhost/upload-to-supercontainer.php',
'contact=0,1:email',
'images=1+',
'video=1+',
'context=<?php echo $images_results_row['Images_key_n'][0]; ?>',
'passcontext=1',
'maxsize=10000,10000',
'edit=1',
'v=1.2'];
window.location = 'vquickpic://?' + getParams.join('&');
};
</script>
<a href="javascript:launchQuickpic();">
<h1>Upload from the Phone.</h1></a>
+_+_+_+_+_+_+_+_+_+_+_+
Here's the upload-to-supercontainer.php file:
<?php require_once('lib/supercontainer.php'); ?>
<?php
// Get the context variable that is coming back from quickpic to determine the SuperContainer directory by Serial
$sc_directory = $_GET['context'];
?>
<?php
// Get the full path to where the site exists
$serverParentDirectory = $_SERVER["DOCUMENT_ROOT"] . '/test/';
// Take the uploaded file and move it to the "upload" directory on the server
foreach($_FILES as $file){
move_uploaded_file($file['tmp_name'], $serverParentDirectory . '/uploads/' . $file['name']);
}
$transferFile = 'uploads/' . 'quickpic.jpg';
// Show the file so you know it exists
print 'image: <img src="http://localhost/test/' . $transferFile . '">';
echo "<br />";
// Get the full path to the file
$serverPath = $serverParentDirectory . $transferFile;
print 'full path: ' . $serverPath;
echo "<br />";
//SuperContainer Stuff
$SC_BASE_URL = 'http://remotehost:80/SuperContainer/Files/images';
$sc = new SuperContainer($SC_BASE_URL);
if ($sc->getError()) die('Could not connect to SuperContainer server: ' . $sc->getError());
$sc->upload($sc_directory, $serverPath)
or die("Could not upload $serverPath to $sc_directory: " . $sc->getError());
?>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20110211/bf7d74a0/attachment.html
More information about the FX.php_List
mailing list