It looks like you're new here. If you want to get involved, click one of these buttons!
public function Upload($Args) {
$Session = Gdn::Session();
// displays the correct user ID
echo $Session->UserID;
$this->Permission('Gallery.Items.Upload');
$this->AddModule('GalleryHeadModule');
$this->AddModule('GallerySideModule');
$this->AddCssFile('uploadify.css');
$this->AddJsFile('jquery.uploadify.js');
$this->Render();
}
/*
* Script for the Uploader to run after sucessful upload
*/
public function UploadProcess() {
$Session = Gdn::Session();
$targetFolder = '/uploads'; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
$Resized = $this->ImageResize($targetFile, $targetFile.'-Thumb.jpg', 100, 100, 0);
if ($Resized) {
$this->StatusMessage = T("Image Sucessfully Resized");
} else {
$this->StatusMessage = T("Image NOT Sucessfully Resized");
}
echo '1';
$ItemModel = new ItemModel();
$Count = $ItemModel->GetCount(array('FileName'=> $fileParts['basename']));
// Now the same call produces a zero instead...
if ($Count > 0) {
$ItemModel->Update('GalleryUpload', array(
'FileName' => $fileParts['basename'],
'InsertUserID' => $Session->UserID,
), array('FileName' => $fileParts['basename']));
} else {
$ItemModel->Insert('GalleryUpload', array(
'FileName' => $fileParts['basename'],
'InsertUserID' => $Session->UserID,
));
}
} else {
echo 'Invalid file type.';
}
}
}
Comments
No cookies -> no identify -> Session->UserID is always 0.
In php you can check TransientKey thus: Update:
This is abstract `$User->TransientKey`, TransientKey stored in Attributes (serialized).
In 2.0.18 there is Session table. I havent seen it in use.
I am only a rookie at php, and I have been reading up on jquery, ajax and json, though any attempts to pass the data along failed yesterday.
Thanks for the direction, though, that gives me somewhere to start today.
Edit:
It still bothers me that this DID work the other day. I just pulled the UserID from Session(), and it did store in the database. Any idea why?
I have tried using Gdn::Request() though I'm not sure how the function works...
Problem was the post was going to the wrong page since I renamed the file; I was wondering where the redirect was coming from.