I have been trying to follow the API Documentation to update a photo using PHP.
I went through the sample code blocks provide, but I really don't understand. May be its missing the detailed explanation. Its doing like
- creating $parts
- creating $newphoto
- changing $parts
What I am doing is like:
When the user clicks on a photo, I get the "id" of the clicked photo. This gives information, that this particular photo needs to be updated. Then I redirect the user to the page for uploading a new photo and set the obtained "id" for photo in hidden field.
Then I don't know what to do exactly to update the photo.
Is my approach wrong? Can anybody suggest me a solution with some sample code.
Thanks.
Tags:
You are on the right track! You just need to add form fields for each of the photo's fields you want members to be able to update. Here is a sketch of the flow of information:
Hello Devin,
You seem to be the only person answer the questions here. Can you please spare some time to answer my question.
Thanks,
Mahendra.
Hey Devin,
Thank you for taking time to reply back. Here is my HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload Photo</title>
</head>
<body>
<div id="logoDiv" style='padding-top: 20px; padding-bottom: 20px;'>
<img src='logodrk.png' alt='logo' />
</div>
<form action="upload.php" method="post" enctype="multipart/form-data">
<p style='padding: 20px'>
<span> Title : </span>
<br />
<input type="text" name="title" id="title" /> <br />
<span> Description : </span>
<br />
<textarea name="description" id="description" cols="50" rows="5"> </textarea>
<br />
<input type="hidden" id="photoIdToUpdate" name="photoIdToUpdate" value="<?php if(isset($_REQUEST["photoId"])) echo $_REQUEST["photoId"]; ?>" />
<input type="hidden" id="email" name="email" value="<?php if(isset($_REQUEST["email"])) echo $_REQUEST["email"]; ?>" />
<input type="hidden" id="password" name="password" value="<?php if(isset($_REQUEST["password"])) echo $_REQUEST["password"]; ?>" />
<?php
if(!isset($_REQUEST["photoId"]))
{
?>
<span> Picture to upload: </span>
<br />
<input type="file" name="file" id="file" />
<br />
<input type='submit' value='Upload' style='width: 100px; text-align: center; padding: 0px;' />
<?php
}
else
{
?>
<br />
<input type='submit' value='Update' style='width: 100px; text-align: center; padding: 0px;' />
<?php
}
?>
</p>
</form>
</body>
</html>
Dear Mahendra,
I'm trying to create a Photo Competition app/section for my network.
My question to you is where are you posting the above photo code ? Is it on your own server or on new Ning pages
on your Ning Network ?
Thanks
- Belal
Belal - the code is posted on Mahendra's own server. It requires PHP, so won't work if you just post it on a Ning page.
Mahendra - as Devin suggested, you should check that you are passing in the photoIdToUpdate parameter correctly. Looking at this part:
<input type="hidden" id="photoIdToUpdate" name="photoIdToUpdate" value="<?php if(isset($_REQUEST["photoId"])) echo $_REQUEST["photoId"]; ?>" />
It seems that the photo ID will only be passed in if $_REQUEST["photoId"] is set. Can you double-check that in the PHP code, by adding in the code in bold?
$parts = array(
"title" => $_POST["title"],
"description" => $_POST["description"],
"id" => $_POST["photoIdToUpdate"]
);
echo '$parts: '; print_r($parts); echo '<hr>';
$result = NingApi::instance()->photo->updateById($parts);
print_r($result);
Try editing the photo, and if it doesn't work, paste the info this prints out into this discussion and let me know the URL of the network you're working against, and I'll check things out.
Posted by Kyle Ford on October 13, 2010 at 8:00am 3 Comments 3 Likes
Posted by Phil McCluskey on October 1, 2010 at 8:55am 0 Comments 1 Like
Posted by Kyle Ford on September 30, 2010 at 8:30pm 1 Comment 1 Like
© 2024 Created by Build Team. Powered by