Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

Graves Robber
($1.99)

African Adventure
($0.99)

iTazer
($0.99)

ArtStudio
($3.99)

Pigs Vs Wolves
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 05-08-2008, 11:23 AM   #3 (permalink)
ddavtian
New Member
 
Join Date: Apr 2008
Posts: 10
Default Re: Need Help Posting an image from iPhone to php page via POST

I have not tried that but I will, here's the php file that will accept the data ...

if(!isset($_REQUEST['sender_email']) || !isset($_REQUEST['ext']) ){

echo "result=fail&errorMsg=invalid request";
exit;
} else {

$headers = 'From: hello@example.com' . "\r\n" .
'Reply-To: hello@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

$email = $_REQUEST['sender_email'];

$msg = "";
foreach ($_REQUEST as $k => $v) {
$msg .= " $k = $v\n";
}



mail($email, "Microphone Check", $msg, $headers);
echo "result=success&email=" . $email;
}

if(isset($_REQUEST['postcard'])){


$ext = $_REQUEST['ext'];

// define the image
$file = $_REQUEST['postcard']; //base64_decode($_REQUEST['postcard']);

// define the file name
$filename = time();

// define destination path to image
$destPath = "../postcards/" . $filename . "." . $ext;

// save the image
try {

@file_put_contents($destPath, $file);

} catch (Exception $ex) {

echo "&result=failed&errorMsg=" . urlencode($ex);
}

}
ddavtian is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 23,754
Threads: 38,524
Posts: 169,208
Top Poster: smasher (2,543)
Welcome to our newest member, labouhassan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:16 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.