Set maximum upload for images with htaccess - .htaccess

I´d like to prevent a user to upload images bigger than a determinated size (i.e. 1 MB) using if possible htaccess.
Thanks for your help

You might use the LimitRequestBody directive. Note how it governs the size of the entire request, so the actual size of the largest allowed file will be smaller. You can combine it with an ErrorDocument 413 to make the error message more user-friendly.
Also, if you're on a shared host, there's a chance the system administrator doesn't allow overriding the value in a htaccess file.

I would suggest the use of "php_value upload_max_filesize" in htaccess file.
Please refer the link below. Though, the example on link given below is for increasing the filesize, you can use the same for limiting the filesize.
http://www.maheshchari.com/increase-php-file-upload-limit/
The link below can also help you. Checkout the section entitled "Modifying the .htaccess file". Though, the example is for moodle, it can give you basic idea to sort-out the problem.
http://docs.moodle.org/23/en/File_upload_size
With all due respect, i would like to add that "php_value upload_max_filesize" is used to limit the filesize. Whereas "LimitRequestBody" directive is used to limit entire body size.
http://httpd.apache.org/docs/2.2/mod/core.html (Checkout the section entitled with "LimitRequestBody Directive")

Related

I have a small code on the end of each image link on my site that I didn't add. Does anybody know what this is?

mywebsiteurl.net/image.jpg?9a7ad6
What is this "?9a7ad6" after each image link? I noticed this when I copy pasted the url of an image.
I googled it, but the only relevant thing that I could find is that #9a7ad6 is the hex code for purple.
Some WordPress themes/plugins use query strings to do neat things to images on the fly like resizing. In this case, the query string (stuff after the ?) is likely being used to prevent caching. If that is the case, here's how to fix it:
There's a setting under Browser Cache → General that says Prevent
caching of objects after settings change → Whenever settings are
changed, a new query string will be generated and appended to objects
allowing the new policy to be applied. Disable that (if you're using
the plugin) and those query strings will be dropped on static
resources like .jpg and .png files.
Source: Philip Arthur Moore from WordPress.org: http://wordpress.org/support/topic/wordpress-32-images-show-weird-query-string
You may also want to take a look at this page: http://diywpblog.com/wordpress-optimization-remove-query-strings-from-static-resources/

htaccess working, but layout broken?

I don't know a huge amount about htacess and modrewrite, so I find myself in yet another predicament approaching this new zone for myself.
I will seperate my Inquiries over 2 different questions to allow answers to be on-topic and better targetted to users searching for solutions to their own questions.
This is the second of those 2 inquiries;
I have the following in my htaccess file;
RewriteRule ^install/([a-zA-Z0-9]+)/$ index.php?module=faq&page=howto&program=$1
The concept is that install/abcd/ would call index.php?module=faq&page=howto&program=abcd
That works. It pulls the content, matches it and shows what it is meant to. I have used server variables to show me what is being simulated and it matches up.
However the CSS and images on the page are being stripped as they are relative to the document, not statically assigned.
I am only using htaccess (For Now I guess?) for one solution, with the intention to soon impliment another fairly soon. The intention is to offer our customers easy to read URL's for support purposes, but not rewriting the entire site. SEO isnt a major issue as our site is only to be used by those it is intended for as opposed to a wide audience.
Other than statically assigning css, JS and image files, is there a way to fix this issue so that the page is displayed styled and with the javascript in tact?
Thanks for your help, I hope the question was understandable and as always I appreciate the time you guys take to help us all!
We need to either make the css links absolute (starts with a /) or add a base for all our relative links by adding an extra attribute to the header:
<base href="/">
This would mean that you we start with the subdirectory of /test/. so instead of the css being;
http://domain.com/install/abcd/style.css
It would instead
http://domain.com/style.css
This is the problem I was having due to all my CSS and JS being included relativly (Allowing me to change the directory my script is in).
The above adjustment has in fact fixed my original problem, however without the use of PHP may open up an issue for some who want to be able to deploy the scripts and allow them to be fully dynamic without having to edit the base. Good luck!

Is there an absolute limit to how much data you can put in mailto: body parameter?

Given I'm creating a mailto: hyperlink. Is there a absolute limit to how much data you can put in mailto: body parameter?
Is this browser dependent?
I believe these is a limit to the mailto URI. And I believe that limit is dependent on the browser.
Check out this question and answers: Getting around mailto / href / url character limit
Like they suggest in that answer, I would suggest doing some sort of server side processing of the data, most likely in a POST over a GET.
Also from that question, this link (http://support.microsoft.com/kb/q208427) was presented and tells that IE has a limit of 2083 characters in a URL.
I think there's a max of 8000 chars in a URI defined in some spec somewhere
More than you'll ever need :)

Increase Snippet Size on Google Search Appliance

I am currently working on customizing a corporate GSA box for the client's website with Goggle's XSL stylesheet.
Unfortunately I do not have direct access to the box, this involves a meeting with a fellow in another timezone, so experiments and learning is very short on my part.
One of the biggest issues we are having is weather or not it is possible to get more characters/words into a resulting search-snippet in the XML output. More specifically, the returned field.
I've gone through a lot of the documentation for this and so far I've only found the tlen value for Title length, but not snippet length.
I know there are some parameters (hidden fields) to customize some options in the search form, but not finding anything relating to this. Since I can not access the Administrator Control panel itself, I've no idea what options are there. Can anyone point me to something that will help with this? It's greatly appreciated, I'm striking out on this.
BTW; we are at the current Version 6.14 I believe.
The GSA administrator can increase the length of the snippet. This is a system wide setting and not able to be customized at query time.
See this
http://www.google.com/support/enterprise/static/gsa/docs/admin/70/admin_console_help/serve_query_expansion.html#snippets
Changing the Snippet Length in Search Results
By default the Search Appliance, for most languages, will return Snippets with the length of 160 characters. Some exceptions to this rule are CJK languages for which Snippets are by default 240 characters. To Change the Snippet Length:
Under Snippet Generation, type a number in the Snippet Length box. The number must be bigger or equal to 0 and not bigger than 1024.
Click Apply Snippets Generation Settings.

sharepoint file upload

I can upload a 250MB file to sharepoint 2007 but nothing larger. I have changed the two webconfig file, set the admin site to 2047MB and it still fails.
Please help this was to be completed asap.
thanx
SPS ignore the file size setting for max file size, according to various testings.
Instead see KB 925083 for info on how to change size http://support.microsoft.com/kb/925083
Please define "fail". Any specific error message, timeouts, etc?
How do you upload your files? Webinterface, WebDav Put, RPC, etc?
When you say "modified web.config", I assume you mean you setting maxAllowedContentLength property of the requestLimits node to something huge. Have you verified you set this correctly, by using small values and checking if it indeed blocks files?
Regarding step 3, or did you mean the executionTimeout setting on the httpRuntime? Verified you set it right by setting it to too small a value an checkin that it cuts short your requests?
By "setting the admin site", I assume you mean you set the Maximum upload size on the Virtual Server Settings page to something hue. Again, have you verified what the behaviour is when you choose too small a value there?
Note how step 3-5 are just the generic checklist shaped like questions... usually it helps going through the steps one more time.
Looks like you have a situation where there are several "gates" that the file has to go through and it is getting caught by the narrowest.
There is also the question is it getting stopped during the upload or when it is being written to sharepoint.
Based on the other answers / cooments sounds like you have checked most things. There are a couple more you could try:
Is there anything in machine.config that is blocking your settings in web.config (typical overrideable = false)
Are the settings cached, have you tried restarting the machine?
here are a couple of links that might help:
http://spsstuff.blogspot.com/2006/03/how-to-change-maximum-file-upload-size.html
http://support.microsoft.com/kb/925083

Resources