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 )
と大丈夫です。