Solved

cant open uploaded file on cakephp

Posted on 2014-10-28
6
123 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 110

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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

Suggested Solutions

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…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

751 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