如何使用 Facebook 在我的应用程序中上传活动创建照片?
嗨
我想在我的应用程序(即事件创建)中上传一张活动照片,并且在我的数据库中,以下是我的代码:
HTML 文件:
<tr>
<td class="style6 style1 style8"><span class="style30">Add Event Photo </span></td>
<td colspan="4"><input name="userfile" type="file" class="style28" id="userfile" size="50" height="25" /></td>
</tr>
<tr>
<td><input name="image" type="image" src="img_2.gif" alt="submit form" border="0" /></td>
</tr>
现在是要上传的 php 代码:
if (isset($_POST['eventtitle'])&& $_FILES['userfile']['size'] > 0){
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
mysql_query("INSERT INTO event values('$uid','$eventID','$newDate','$newtime','$newDate2','$newtime1','$name','$location','$street','$city','$fileName', '$fileSize', '$fileType','$content','$description')");
mysql_close($con);
?>
name
、size
、type
和 content 是图像的字段。
Hi
I want to upload a event photo in my app ie event create and also in my database the following is my code:
HTML file:
<tr>
<td class="style6 style1 style8"><span class="style30">Add Event Photo </span></td>
<td colspan="4"><input name="userfile" type="file" class="style28" id="userfile" size="50" height="25" /></td>
</tr>
<tr>
<td><input name="image" type="image" src="img_2.gif" alt="submit form" border="0" /></td>
</tr>
now the php code to upload:
if (isset($_POST['eventtitle'])&& $_FILES['userfile']['size'] > 0){
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
mysql_query("INSERT INTO event values('$uid','$eventID','$newDate','$newtime','$newDate2','$newtime1','$name','$location','$street','$city','$fileName', '$fileSize', '$fileType','$content','$description')");
mysql_close($con);
?>
name
, size
, type
and content
are fields for the image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我两天前写了一篇关于此的教程: 如何:使用 Graph API 创建 Facebook 事件 – 高级
示例代码:
我建议您阅读本教程以及同一篇文章中链接的上一篇教程以获取更多信息。
Well, I've written a tutorial about this two days ago: How To: Create Facebook Events Using Graph API – Advanced
Sample code:
I recommend you read the tutorial and the previous one linked in the same article for more information.