Return photo ID when upload successful #487

This commit is contained in:
Tobias Reich 2016-03-24 18:40:58 +01:00
parent 7bb2a61829
commit d212363ebf
4 changed files with 6 additions and 4 deletions

BIN
dist/main.js vendored Normal file → Executable file

Binary file not shown.

View File

@ -231,7 +231,7 @@ final class Admin extends Access {
Validator::required(isset($_FILES, $_POST['albumID']), __METHOD__);
$photo = new Photo(null);
Response::json($photo->add($_FILES, $_POST['albumID']));
Response::json($photo->add($_FILES, $_POST['albumID']), JSON_NUMERIC_CHECK);
}

View File

@ -39,7 +39,7 @@ final class Photo {
* Creats new photo(s).
* Exits on error.
* Use $returnOnError if you want to handle errors by your own.
* @return boolean Returns true when successful.
* @return string|false ID of the added photo.
*/
public function add(array $files, $albumID = 0, $returnOnError = false) {
@ -251,7 +251,7 @@ final class Photo {
// Call plugins
Plugins::get()->activate(__METHOD__, 1, func_get_args());
return true;
return $id;
}

View File

@ -96,10 +96,12 @@ upload.start = {
let wait = false
let errorText = ''
const isNumber = (n) => (!isNaN(parseFloat(n)) && isFinite(n))
file.ready = true
// Set status
if (xhr.status===200 && xhr.responseText==='true') {
if (xhr.status===200 && isNumber(xhr.responseText)) {
// Success
$('.basicModal .rows .row:nth-child(' + (file.num + 1) + ') .status')