Skip to content →

新浪SAE笔记1

成功申请新浪SAE中级开发者有一段时间了,下面记录一下在sae上开发时常用到的代码:

SAE环境中上传文件到Storage
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html;charset=utf-8″ />
<title>上传文件</title>
</head>
<body>
<form enctype=”multipart/form-data” action=”upload.php” method=”post”>
<input name=”myfile” type=”file”/>
<input type=”submit” value=”上传”/>
</form>
</body>
</html>

<?php
//SAE环境中上传文件到Storage
$storage = new SaeStorage();
$domain = ‘fine’;
$destFileName = $_FILES[‘myfile’][‘name’];
$srcFileName = $_FILES[‘myfile’][‘tmp_name’];
echo $storage->upload($domain, $destFileName, $srcFileName, -1, $attr, true);
echo “<br/>”;
echo $storage->getUrl($domain,$destFileName);//输出文件在storage的访问路径
?>

登录界面验证
<script language=”JavaScript”>
function CheckForm(theForm)
{
if(theForm.textfield.value.length==0){
alert(“请输入账户!”);
theForm.textfield.focus();
return false;
}else{
if(theForm.password.value.length==0){
alert(“请输入密码!”);
theForm.password.focus();
return false;
}
}
return true;
}
</script>

<form ACTION=”<?php echo $loginFormAction; ?>” name=”form1″ method=”POST” onSubmit=”return CheckForm(this)”>
SAE数据库连接:
<?php
# FileName=”Connection_php_mysql.htm”
# Type=”MYSQL”
# HTTP=”true”
$hostname_blog = SAE_MYSQL_HOST_M.’:’.SAE_MYSQL_PORT;
$database_blog = SAE_MYSQL_DB;
$username_blog = SAE_MYSQL_USER;
$password_blog = SAE_MYSQL_PASS;
$blog = mysql_connect($hostname_blog, $username_blog, $password_blog);
?>

Published in Web

Comments

发表评论

电子邮件地址不会被公开。 必填项已用*标注