I wrote a Facebook app from PHP and HTML that work perfect in the Opera browser, but doesn’t work in Internet Explorer or Google Chrome.
The page index of the app is at: http://apps.facebook.com/zbtmajik/
After you choose an image to upload and choose the ‘Upload’ button, it is supposed to redirect to http://majik.zbrowntechnology.info (inside the iframe ) and keeps redirecting to
http://majik.zbrowntechnology.info/?auth_token=e0afbd3167ae943a94b41e940298f2d1&next=http%3A%2F%2Fmajik.zbrowntechnology.info%2Fupload.php
I think it might be an issue with the iframe since it seems like when I submit the form, it attempts to redirect the entire page instead of just what is in the iframe.
I have know idea what the problem is, but it is for work and I need to get it fixed. Any help would result in your name on a thank you page on the app!
_____ upload.php____________________________________________________________________
I was told that it may be the PHP code that processes the upload, so here it is:
<?php
include_once('facebook.php');
$appapikey = 'API KEY HERE';
$appsecret = 'SECRET KEY HERE';
$facebook = new Facebook($appapikey, $appsecret);
$fb_user = $facebook->require_login();
if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) {
$filename = basename($_FILES['uploaded_file']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") &&
($_FILES["uploaded_file"]["size"] < 350000)) {
$newname = dirname(__FILE__).'/upload/zbt_'.$fb_user.'.jpg';
if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) {
header("Location: http://majik.zbrowntechnology.info/display.php");
} else {
header("Location: home.php?Fatal");
}
} else {
header("Location: home.php?Fatal");
}
} else {
header("Location: home.php?Fatal");
}
?>
I have looked over it and can’t seem to find anything, but I’m not a very strong PHP programmer either.
I looked over the code again in the PHP doc, and found that the problem lies on this line: if((!empty($_FILES[“uploaded_file”])) && ($_FILES[‘uploaded_file’][‘error’] == 0)) {. Not sure exactly what it is though.
I have looked at your PHP script in the question. As we have eliminated the redirect as the cause of the problem, let’s look at the upload handler.
I have rewritten the script, and included a pile of debug messages, and I have also added a line which will delete an existing file if a user uploads a second one.
If/when it works, remove anything between the
/* DEBUG CODE - XXX */sets.