Skip to main content
Topic: File Upload 403 error (Read 3140 times) previous topic - next topic

File Upload 403 error

Hi!

I upload files to product server. If the filesize bigger then 5MB, In files field Ihave error:
"Server responded 403 error"
Under Chrome DevTools: 403 Cross-Site Request Forgery-Detected. Please contact the administrator for more information.

Under Win + XAMPP work perfect, but I get error uner CentOS.

Other settings:
- enable Enable CrossCSRFCheck
- enable FormFieldValidationRequest
- enable EnableXSSFilter

What's the problem?
THX!

Re: File Upload 403 error

Reply #1
@machobymb‍ this is an issue with your server configuration and not phprad.
1. Make sure your server PHP max file upload size is set to a higher number compared to the file you are trying to upload.
2. Make sure you are not using ModSecurity or the likes of it, on your server. If you are, then read the manual on how to exempt the file upload request from it.
3. Check the links the request is being made to in Chrome DevTools, that it is the same as the link the project is being served from.

Re: File Upload 403 error

Reply #2
The uploading work under Win 10 + XAMPP. ModSecurity is disabled under CentOS.


Re: File Upload 403 error

Reply #4
New Question: if the Upload working correct, stored full path. If I clicking to Hyperlink, the get "404 -Page Not Found"
"UploadsController Was Not Found In Controller Directory. Please Check app/controllers/"

After updateing record the file uploaded, but after is deleted and the link is stored, when I click to Update button.

What's the problem?

THX!

Re: File Upload 403 error

Reply #5
@machobymb‍ if you stored full path and the URL is not pointing to the current server your project is hosted on, you get such error. So make sure your image link is pointing to your current server. If you want to avoid such errors in the future, set ReturnFullPath to False and re-upload your images or for example, remove the http://yourserverlink from http://yourserverlink/uploads/files/sampleimage.png, and you should be left with something like this /uploads/sampleimage.png.

Re: File Upload 403 error

Reply #6
My Uploader config:
"title" => "{{file_name}}",
"extensions" => ".pdf",
"limit" => "10",
"filesize" => "20",
"returnfullpath" => false,
"filenameprefix" => "modul1-",
"uploadDir" => "uploads/files"

After uploading, then update the record, and the file is deleted from uploads/files directory :(

PHP Garbage Collector problem?


Re: File Upload 403 error

Reply #8
If I remove from FileHelperController.php the line 49. (from removefile() function), then didn't delete the uploaded PDF:
Code: [Select]
echo unlink($file_dir);

BUT the generated link is correct and it don't open in browser: "404 error, uploads Action Was Not Found In mytableController"   :'(


Re: File Upload 403 error

Reply #10
I wrote and complained sooner than I look at what the problem is. The link was not generated correctly.

 

Re: File Upload 403 error

Reply #11
The problem was in my head:) Solution: File list is Custom type field: a comma separated list.
Code: [Select]
 <span>
 <?php
 if (strlen($data['field'])>0) {
    $urls = explode(',', $data['field']);
    $i = 0;
    foreach($urls as $url) {
        $i++;
        echo $i.'.) <a href="'.SITE_ADDR.$url.'">'.basename($url).'</a><br/>';
    }
 } else {
     echo '-';
 }
 ?>
 </span>