Move the old JS uploader backend libs out from the CoreLibs
They are not CoreLibs and so they moved one level up and were renamed "FileUpload"
This commit is contained in:
31
www/lib/FileUpload/Core/qqUploadedFileForm.inc
Executable file
31
www/lib/FileUpload/Core/qqUploadedFileForm.inc
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace FileUpload\Core;
|
||||
|
||||
/**
|
||||
* Handle file uploads via regular form post (uses the $_FILES array)
|
||||
*/
|
||||
class qqUploadedFileForm
|
||||
{
|
||||
/**
|
||||
* Save the file to the specified path
|
||||
* @return boolean TRUE on success
|
||||
*/
|
||||
public function save($path)
|
||||
{
|
||||
if (!move_uploaded_file($_FILES['qqfile']['tmp_name'], $path)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function getName()
|
||||
{
|
||||
return $_FILES['qqfile']['name'];
|
||||
}
|
||||
public function getSize()
|
||||
{
|
||||
return $_FILES['qqfile']['size'];
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
46
www/lib/FileUpload/Core/qqUploadedFileXhr.inc
Executable file
46
www/lib/FileUpload/Core/qqUploadedFileXhr.inc
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace FileUpload\Core;
|
||||
|
||||
/**
|
||||
* Handle file uploads via XMLHttpRequest
|
||||
*/
|
||||
class qqUploadedFileXhr
|
||||
{
|
||||
/**
|
||||
* Save the file to the specified path
|
||||
* @return boolean TRUE on success
|
||||
*/
|
||||
public function save($path)
|
||||
{
|
||||
$input = fopen("php://input", "r");
|
||||
$temp = tmpfile();
|
||||
$realSize = stream_copy_to_stream($input, $temp);
|
||||
fclose($input);
|
||||
|
||||
if ($realSize != $this->getSize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$target = fopen($path, "w");
|
||||
fseek($temp, 0, SEEK_SET);
|
||||
stream_copy_to_stream($temp, $target);
|
||||
fclose($target);
|
||||
|
||||
return true;
|
||||
}
|
||||
public function getName()
|
||||
{
|
||||
return $_GET['qqfile'];
|
||||
}
|
||||
public function getSize()
|
||||
{
|
||||
if (isset($_SERVER["CONTENT_LENGTH"])) {
|
||||
return (int)$_SERVER["CONTENT_LENGTH"];
|
||||
} else {
|
||||
throw new Exception('Getting content length is not supported.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
Reference in New Issue
Block a user