0

Hi I have the following problem. I use jQuery file upload plugin and want to implement file uploader in one of my website pages. I am using the UI version so the thing is working, the files are uploaded but when i try to delete them i have an 404 error on the request. I am using POST request. The problem is that I get 404 header error and that is screwing the code. My page is responding with the right JSON data but the header is 404 I searched the whole [uploader class][3], but i can't find where the header is set and even if I comment that 404 line

if (!$this->is_valid_file_object($file_name)) { return $this->header('HTTP/1.1 404 Not Found'); }

Nothing happens so I cant understand where in which javascript file or in the upload handler class the headers go wrong and how to fix the problem.

So my ajax return is like follows:

_method:DELETE /my_domaing/some_page/uploadAction/file:action_test_file_3%20%281%29.doc

POST 404 Not Found text/plain jquery.js:8706 Script 991 B 360 B 20 ms 20 ms

I think the problems comes from my framework cause in plain php I can upload and delete files. But when i open the page in my browser with that link I can see the JSON response which is:

{"file":{"name":"action_test_file_3.doc", "size":61440,
"url":"http:\/\/my_domain\/files\/action_test_file_3.doc",
"deleteUrl":"http:\/\/my_domain\/some_page\/uploadAction\/file:action_test_file_3.doc\/
_method:DELETE\/file:action_test_file_3.doc\/_method:DELETE","deleteType":"POST"}}

I don't know what I need to get so the file be deleted, but I know that the header information is gone wrong cause I can open it and see the information but the POST request sees the 404 error and just doesn't do nothing.

The framework I use have a .htaccess rewrite rule which is the following:

RewriteEngine On
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|htc|txt|doc|docx|xls|xlsx|pdf|htm|html|
bmp|flv|xml|zip|plist|ipa|woff|ttf|svg|eot)|^design(.*)|^sks(.*)$ index.php

But I don't think the rule has anything to do with this upload. My framwork uses Smarty. I really can't find the way to solve the problem the uploading is working perfectly so why not the deleting. And I have write/delete permissions on the directory.

I don't get any javascript errors and in my php log there are not errors regarding this page.

So I think the problem is with the header information and if it returns 404 the file is just not deleted that is all. But I can't understand where and how this is happening.

So feel free to ask me anything but I can't send you a live demo cause it is a developer server, but I will do anything to try and resolve this problem cause I am struggling with it for almost 2 days. Any help is and will be appreciated!

2
  • Let's check if you are actually sending the request to the right page. Try putting echo('Check me!'); exit(0); at the beginning of the PHP code. Your Ajax call should return "Check me!".
    – Broxzier
    Jul 24, 2013 at 6:56
  • Yes I am sending to the right page if i wasn't the upload wouldn't be working at all. So that's for sure not the problem and I said that I get the JSON response code which you can see there I just get the 404 error in the header information for the request. Jul 24, 2013 at 7:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.