<? echo “\n”; ?>
body {
font: 10px arial;
color: #6EB222;
background-color: #fff;
padding: 10px;
margin: 200px;
}
THE BRADDOCK SIGN PROJECT
please submit your sound
“3gp”,
“audio/aif”=>”aif”,
“audio/x-wav”=>”wav”,
“video/mp4″=>”mp4″,
“video/3gpp2″=>”3g2″,
“video/mpeg”=>”mpg”,
“video/quicktime”=>”mov”,
“video/x-quicktime”=>”mov”,
“video/x-msvideo”=>”avi”,
“image/jpg”=>”jpg”,
“image/jpeg”=>”jpg”,
“image/png”=>”png”,
“audio/vnd.wave”=>”wav”
);
// Make sure form was submitted
if (isset($_POST['form_submitted']) && $_POST['form_submitted'] == “true”)
{
// Check the mime type
$allowed_types = array_keys($allowed_mime_types);
$allowed = false;
if (isset($_FILES['bytes']['type']))
{
for ($i = 0; $i < sizeof($allowed_types) && !$allowed; $i++)
{
if (strstr($_FILES['bytes']['type'], $allowed_types[$i]))
{
$allowed = true;
}
}
// If the mime type is good, save it..
if ($allowed)
{
$uploadfilename = time() . “_” . rand(1000,9999) . “_” . basename($_FILES['bytes']['name']);
// Make sure apache can write to this folder
$uploaddir = ‘/home/sw1146/public_html/MOBILEMEDIA/php_popper/posts/’;
$uploadfile = $uploaddir . $uploadfilename;
$uploadrelativefile = ‘http://itp.nyu.edu/~sw1146/MOBILEMEDIA/php_popper/posts/’ . $uploadfilename;
if (move_uploaded_file($_FILES['bytes']['tmp_name'], $uploadfile))
{
// Make sure the file isn’t executable and you can delete it if you need
chmod($uploadfile, 0666);
// Put it in the database
/* Database Table:
mobile_me_messages
message_id int(11) auto_increment
attachment varchar(255)
subject varchar(255)
body varchar(255)
from_name varchar(255)
from_domain varchar(255)
*/
$subject = “”;
$message_text = “”;
if (isset($_POST['subject']))
{
$subject = $_POST['subject'];
}
if (isset($_POST['message_text']))
{
$message_text = $_POST['message_text'];
}
// Connect to the database
$mySql = sqlConnect();
// Insert Data
$query = “insert into mobile_me(attachment, subject, body, from_name, from_domain) values (‘” . $uploadfile . “‘, ‘” . $subject . “‘, ‘” . $message_text . “‘, ‘mobile web user’, ‘mobile web user’)”;
$result = mysql_query($query, $mySql);
// Disconnect from the database
mysql_close($mySql);
// Tell the user
echo ”
Success
” . $uploadrelativefile . “
“;
}
else
{
echo ”
Error on upload…!
“;
}
}
}
}
else
{
?>
Phone (iPhone) doesn’t support file uploads? Email it instead..