Solved

cant open uploaded file on cakephp

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

895 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

13 Experts available now in Live!

Get 1:1 Help Now