Return photo ID when upload successful #487
This commit is contained in:
parent
7bb2a61829
commit
d212363ebf
BIN
dist/main.js
vendored
Normal file → Executable file
BIN
dist/main.js
vendored
Normal file → Executable file
Binary file not shown.
@ -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…
Reference in New Issue
Block a user