I am newbie with iPhone programming. I have a task that upload image from iphone to server and store it in Mysql database on server. After that I retrieve the image from database and display it on iPhone.
- On Upload:I used ASIFormDataRequest to send image data to server and a PHP script (uploadpicture.php) will store image data to database with blob datatype.
- On Download:I used NSURLRequest with NSURLConnection and a PHP script (downloadpicture.php) to retrieve image from database and send it back to iphone.This is a PHP script:$con = mysql_connect("localhost:8889", "root", "root");if (!$con) { echo "can not connect database"; die("Could not connect: " .mysql_error());}echo "Connect database succesfully";mysql_select_db("myDatabase", $con);$result = mysql_query("select * from pictures" ,$con);while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "{$row['id']}"; echo "{$row['title']}"; echo "{$row['description']}"; echo "{$row['image']}"; echo "{$row['rate']}"; echo "{$row['numberofrate']}"; echo "{$row['numberofdownload']}"; echo "{$row['numberofcomment']}"; echo "
";}mysql_close($con);echo "completed";