我想从我处理上传的PHP代码中返回一个错误.
目前,如果php上传失败,JS仍然认为它成功了,我认为这与它返回的事实有关.
我试过返回false而不是字符串,但仍然运行this.on('success')函数.
PHP
public function imageUpload(){
//?heck that we have a file
if((!empty($_FILES["file"])) && ($_FILES['file']['error'] == 0)) {
//Check if the file is JPEG image and it's size is less than 350Kb
$filename = basename($_FILES['file']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
if (($ext == "jpg") && ($_FILES["file"]["type"] == "image/jpeg") &&
($_FILES["file"]["size"] < 3500000)) {
//Determine the path to which we want to save this file
$newname = '/home/anglicvw/public_html/newdev/app/templates/default/images/testimages/'.$filename;
//Check if the file with the same name is already …Run Code Online (Sandbox Code Playgroud)