Return photo ID when upload successful #487

pull/475/head
Tobias Reich 8 years ago
parent 7bb2a61829
commit d212363ebf

2
dist/main.js vendored

File diff suppressed because one or more lines are too long

@ -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);
}

@ -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;
}

@ -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')

Loading…
Cancel
Save