Solved

cant open uploaded file on cakephp

Posted on 2014-10-28
6
116 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 108

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 42

Expert Comment

by:Rob Jurd, EE MVE
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 42

Accepted Solution

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now