MuchDev Posted October 4, 2014 Share Posted October 4, 2014 I am trying to have the ability to have a link on my navigation download a pdf catalog. I have a field named "file" that I use for these types of instances, but after just testing it I am now realizing that I may have an .htaccess issue. Is there simple rule that would allow me to output a file download link by just using $page->file->url? When I try and generate a link I get a propper path to the exact asset folder but then the link causes a 403. Should I approach a file download a different way then this? Link to comment Share on other sites More sharing options...
MuchDev Posted October 4, 2014 Author Share Posted October 4, 2014 Interesting thing, I have gone investigating a bit further and for some reason the file upload is failing partially after upload. I end up with 60kb before it fails. Looks like I may have a timeout issue. Link to comment Share on other sites More sharing options...
MuchDev Posted October 4, 2014 Author Share Posted October 4, 2014 K after going in and increasing all of my memory limits in my php ini I am back in business. Looks like having my core memory limit at the default 128M was too low, so I went and bumped it to 256. I have a deecent server, should I go and bump this even higher, like 512+? 1 Link to comment Share on other sites More sharing options...
gebeer Posted October 7, 2014 Share Posted October 7, 2014 I don't know about bumping the limit further up. But when setting up file downloads, there are some useful functions in the API that you could use. E.g. if you want to allow downloads only for certain users. Here's a post that helped.me.out: https://processwire.com/talk/topic/3634-down-uploads-on-a-per-user-policy/ 1 Link to comment Share on other sites More sharing options...
sforsman Posted October 7, 2014 Share Posted October 7, 2014 I am trying to have the ability to have a link on my navigation download a pdf catalog. I have a field named "file" that I use for these types of instances, but after just testing it I am now realizing that I may have an .htaccess issue. Is there simple rule that would allow me to output a file download link by just using $page->file->url? When I try and generate a link I get a propper path to the exact asset folder but then the link causes a 403. Should I approach a file download a different way then this? The 403 means there's something wrong with your .htaccess -file or you are trying to access the asset-folder itself (and not an actual file inside there). Could you show us the link and/or code? K after going in and increasing all of my memory limits in my php ini I am back in business. Looks like having my core memory limit at the default 128M was too low, so I went and bumped it to 256. I have a deecent server, should I go and bump this even higher, like 512+? This shouldn't have anything to do with the 403 you were getting. 128M is perfectly fine for basic web page -stuff. There might be some serious design errors in your code if you are hitting the memory limit, I'm afraid If you could tell us a bit more - paste actual code and so on - we could help more. How large are the catalogs you are uploading? 1 Link to comment Share on other sites More sharing options...
MuchDev Posted October 7, 2014 Author Share Posted October 7, 2014 So in the end my issue seemed to be in the processwire backend. I was trying to keep a simple file link of the companies’ current pdf catalog on the navigation at the top of the screen. I just wanted the client to be able to continue to release their catalogs in the format that they are use to. I have a template at the root of my page structure that contains global settings like logos and widgets. Inside of this template I have a file field that holds a downloadable file (a pdf). My issue was when I tried to upload the file it would show complete on the form, and then when one would try and click the link to the file there would be an error, and I would get a 403. The code that I used to generate the link was basically just this: <a href="<?php echo $page->file->url;?>">Link to the thing</a> The path that it generated was the correct path inside of my asset folder with the propper link, but as it was a bad file I was getting an error. The PDF was about 52mb. When I increased my memory limit processwire then was completing the upload of the file, and the download links would then work. As to why this was the case I am unsure, but as the code for my site is pretty basic I am fairly certain I was just having a memory issue. At this time I was also having some other issues with pro cache failing that seemed to be fixed when I switched over from fcgi to cgi processing. Link to comment Share on other sites More sharing options...
kongondo Posted October 7, 2014 Share Posted October 7, 2014 If it is a memory issue it really has nothing to do with PW but PHP These would be useful http://php.net/manual/en/features.file-upload.common-pitfalls.php http://stackoverflow.com/questions/5106871/relationship-between-php-s-memory-limit-upload-max-filesize-and-post-max-filesi http://php.net/manual/en/ini.core.php https://processwire.com/talk/topic/2190-max-file-size-for-uploading-a-file/ https://processwire.com/talk/topic/2194-flie-upload-max-file-size/ Link to comment Share on other sites More sharing options...
MuchDev Posted October 7, 2014 Author Share Posted October 7, 2014 If it is a memory issue it really has nothing to do with PW but PHP Forgive my ignorance:D These would be useful http://php.net/manual/en/features.file-upload.common-pitfalls.php http://stackoverflow.com/questions/5106871/relationship-between-php-s-memory-limit-upload-max-filesize-and-post-max-filesi http://php.net/manual/en/ini.core.php https://processwire.com/talk/topic/2190-max-file-size-for-uploading-a-file/ https://processwire.com/talk/topic/2194-flie-upload-max-file-size/ Thanks! The two processwire links I've read which is what got me through the issue. I'll read into those top 3 tonight. Youre a star! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now