Uploading Image Error

I am trying to set u a field, in longblob, to hold an image file in the database. I have set up an upload field to upload an image. Now, whenever I try to upload an image, I will get this error:File not found image.png
SyntaxError: Unexpected token < in JSON at position [some number]I am using PHPMaker 2020.0.11

You may debug by:

Check the HTTP response from the API when you upload, find HTTP request to /api/index.php?action=jupload. You will see the full error message in the HTTP response.

I finally found the culprit: my installation of XAMPP. All I did was to re-install XAMPP, fired Apache and MySQL and it worked fine. Thank you all for your inputs!

:smiley: … same getting the issue.

I have the same issue when tryting to upload image (edit/add view).
(file not found <filename) followed by “SyntaxError: Unexpected token < in JSON at position 662 after uploading an image”).
I noticed the image is shortly shown and I see a progress bar evolving but after a fraction of a second, the above error appears)

  • I Changed post_max_size in php.ini as suggested by xxltomcat → same issue
  • I Re-installed XAMPP as suggested by bernierei → same issue
  • Debug via ewcfg.php → no errors in PHP, but error still the same
  • PHP error reporting was set to E_ALL.
    → So final debug method via F12 - Network Response:
    {“files”:[{“name”:“ccf_000004.jpg”,“size”:241430,“type”:“image/jpeg”,“url”:“api/index.php?action=jupload&rnd=2021518739&id=x_pic&table=bedrijveninfo&session=Uf3TeI1RGMgaGgJ9aXrHsAP5fSIy6n-te9vPbjxSnB8.&x_pic=ccf_000004.jpg&download=1”,“thumbnailUrl”:“api/index.php?action=jupload&rnd=2021518739&id=x_pic&table=bedrijveninfo&session=Uf3TeI1RGMgaGgJ9aXrHsAP5fSIy6n-te9vPbjxSnB8.&x_pic=ccf_000004.jpg&version=thumbnail&download=1”,“deleteUrl”:“api/index.php?action=jupload&rnd=2021518739&id=x_pic&table=bedrijveninfo&session=Uf3TeI1RGMgaGgJ9aXrHsAP5fSIy6n-te9vPbjxSnB8.&x_pic=ccf_000004.jpg&_method=DELETE”,“deleteType”:“POST”,“extension”:“jpg”,“exists”:true}]}

    Notice: Trying to access array offset on value of type null in C:\xampp\htdocs\amb_v22_tst\classes\UploadHandler.php on line 500

Uploadhandler.php (from line 499 - 508)
499 // Keep an existing filename if this is part of a chunked upload:
500 $uploaded_bytes = $this->fix_integer_overflow((int)$content_range[1]);
501 while (is_file($this->get_upload_path($name))) {
502 if ($uploaded_bytes === $this->get_file_size(
503 $this->get_upload_path($name))) {
504 break;
505 }
506 $name = $this->upcount_name($name);
507 }
508 return $name;

Any advice on what could be done to solve the issue?

Change:
$uploaded_bytes = $this->fix_integer_overflow((int)$content_range[1]);

to:
$uploaded_bytes = $this->fix_integer_overflow((int)@$content_range[1]);

hii all,
i’ve change from xampp to wamp, and run perfecto.

Thank you!

this has solved the issue.

Hi,
I used phpmaker 2020. I get a notification when I upload photos.
This is: File not found (filename.png) SyntaxError: Unexpected token < in JSON at position 757
Please help me!!

arbei wrote:

You may debug by:

Check the HTTP response from the API when you upload, find HTTP request to
/api/index.php?action=jupload. You will see the full error message in the HTTP
response.

Got the same error in 2020.12 version

File not found
SyntaxError: Unexpected token < in JSON at position 0

But it show the file in a flash and also shows the size of the file coorect.

Fatal error: Class ‘UploadHandler’ not found in C:\inetpub\wwwroot\test\classes\FileUploadHandler.php on line 5

Dadinos2 wrote:

Fatal error: Class ‘UploadHandler’ not found in C:\inetpub\wwwroot\test\classes\FileUploadHandler.php on line 5

Make sure you have generated and uploaded all files (including the UploadHandler.php in the “classes” folder).

arbei wrote:

Change:
$uploaded_bytes = $this->fix_integer_overflow((int)$content_range[1]);> to:
$uploaded_bytes = $this->fix_integer_overflow((int)@$content_range[1]);

I’ve encountered the same issue with this line.
Any idea why $content_range is null ?

You use old file, see latest jQuery File Upload source code.