function userSingin( )
{
$login = Common::getGLOBALS('userLogin');
$pass = Common::getGLOBALS('userPassword');
$reg = false;
$users = $this->db->get("SELECT userID, userLogin, userPassword FROM Users");
foreach( $users as $_users )
{
if( $_users->userLogin == $login && $_users->userPassword == md5( $pass ) )
{
//$sess->Set('userHash', md5( $login.$pass.$salt ) );
Session::Set('UID', $_users->userID ); // set userID
$reg = true;
}
}
echo $reg ? "ok" : "error";
}
=================================================
$(function()
{
$('#file_upload').uploadify(
{
'fileSizeLimit' : '1000KB',
'queueSizeLimit' : 1,
'fileTypeDesc' : 'Image Files',
'fileTypeExts' : '*.gif; *.jpg; *.png',
'removeTimeout' : 3,
'swf' : '/application/userData/js/uploadify/uploadify.swf',
'uploader' : '/ajax/uploadAvatar/',
'onUploadError' : function(file, errorCode, errorMsg, errorString) {
alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
},
'debug' : true
});
});
=================================================
public function uploadAvatar()
{
//include_once("application/Tools/Resize.php");
$targetFolder = '/application/userData/upload/avatars/';
if ( !empty ( $_FILES ) )
{
$tempFile = $_FILES['Filedata']['tmp_name'];
$fName = $_FILES['Filedata']['name'];
$exp = explode( '.', $fName );
$ext = end( $exp );
$newName = md5( $_FILES['Filedata']['name']. rand( 1, PHP_INT_MAX ) );
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $newName.'.'.$ext;
$fileTypes = array('jpg','jpeg','gif','png');
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo 'file uploaded';
} else {
echo 'Invalid file type.';
}
}
print_r( $_SESSION ); // empty...
}
=================================================
当我使用print_r( $_SESSION )
时,在另一个文件中就可以了。
答案 0 :(得分:1)
这是我在做Flex时遇到的一个问题,通过Flash上传似乎不使用cookie(从而失去会话)。如果uploadify使用flash,这就是你的问题。
您可以通过设置标识用户的令牌来修复它,而不是上传到http://example.com/upload.php您应该上传到http://example.com/upload.php?token=azpodkazpoj1dzapdo(您上传的脚本必须实现一种机制来查找和检查用户令牌。
编辑:根据疑似重复问题的建议,您可以将session_id用作令牌