Solved

cant open uploaded file on cakephp

Posted on 2014-10-28
6
121 Views
Last Modified: 2014-12-11
Hi, I am trying to open a file that has been uploaded to attachments folder on a cakephp project. I have a list of files I select after uploading . This works fine on my PC but on the remote server it is throwing a 503 error which I have no idea in what to do . The error logs show nothing.

 public function download2($attachment_id = null){
		
		$file = $this->Tutor->Attachment->find('first', array('conditions' => array('Attachment.id' => $attachment_id), 'recursive' => -1));
		//pr($file); die;
		if(!empty($file)){
    		$this->response->file($file['Attachment']['url'], array('name' => $file['Attachment']['org_filename']));
			//Return reponse object to prevent controller from trying to render a view
			return $this->response;			
		}    	
		else{
			$this->Session->setFlash(__('Error encountered while downloading the file. Please, try again.'),'flash_alert');
		}
		
   }

Open in new window

0
Comment
Question by:jagguy
  • 2
  • 2
6 Comments
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40408398
The 5XX errors are server failures, and it may have nothing to do with your uploaded files.
503 Service Unavailable
    The server is currently unavailable (because it is overloaded or down for maintenance).
Refs:
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html (see 10.5.4)
0
 

Author Comment

by:jagguy
ID: 40410653
no this is a cakephp problem masking as a server error. I know this from past problems people have but fixing it isnt clear
0
 
LVL 43

Expert Comment

by:Rob
ID: 40470924
What I would do is isolate this as being either PHP or within the Cake framework.

The PAQ'd question has a test script that I suggest you try on your server to do a simple file upload: http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28454668.html

IF the file upload works fine then you know it's a configuration setting in cake that's causing the issue.  However if it doesn't work then it could be a PHP configuration difference (such as max file size) between your PC and your server.

Please report back your findings.
0
 

Author Comment

by:jagguy
ID: 40485830
I tried a new server and it works
0
 
LVL 43

Accepted Solution

by:
Rob earned 500 total points
ID: 40485836
So that sounds like it was a php issue.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question