I am dealing with PHP File Upload. First I am trying with Just HTML/PHP code without any uploaders (uploadify) etc.
The HTML Code
<form method="post" action="" enctype="multipart/form-data">
<label for="upload">Select : </label>
<input type="file" name="file_upload" id="upload" multiple="multiple" />
<!-- 1024 x 1024 x 1024 -->
<input type="hidden" name="MAX_FILE_SIZE" value="1073741824" />
<input type="submit" name="fsubmit" id="fsubmit" value="Upload" />
</form>
The PHP Code
if (isset($_FILES['file_upload']) && $_FILES['file_upload']['error'] == 0) {
move_uploaded_file($_FILES[$field_name]['tmp_name'], '../somepath/.../' . $_FILES['file_upload']['name');
} else {
echo $_FILES['file_upload']['error'];
}
It is uploading the files less then 8Mb. To override the PHP default I change .htaccess to this and restarted apache.
php_value upload_max_filesize 1024M # also tried "1024M"
php_value post_max_size 1024M # also tried "1024M"
php_value max_execution_time 3600
php_value max_input_time 3600
But no luck, it always takes default 8M. I also try to change the settings from PHP code on the fly like this
ini_set('upload_max_filesize', '1024M');
ini_set('post_max_size', '1024M');
ini_set('max_execution_time', '600');
ini_set('max_input_time', '600');
ini_set('memory_limit', -1); // no memory limit
This has also no effect, when I echo ini_get('post_max_size') it shows 8M. The error code return is 2. Show PHP says
UPLOAD_ERR_FORM_SIZE
Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
Now my question is Why it is not able to override from .htacess or PHP code? NOTE I am on VPS server. When I change 8M to xM manually it works. Hope I am clear, thanks in advance...
It seems you missed to add "AllowOverride All" in apache config for the site directory...because of this your values in htaccess are not overridden..
check these links
http://forum.owncloud.org/viewtopic.php?f=8&t=1809
http://blog.triphp.com/lessons/htaccess/allow-override
Hope it helps !
If you edit directly php.ini with something like this:
php_value upload_max_filesize 750M
php_value post_max_size 750M
and it works, what's the problem? You are not being able to do it in the other way, but what's wrong this way?
Related
Maximum upload size in my case was only 1 MB. I started to search in settings in the WordPress dashboard but no any settings for that, started to solve it by finding few errors and recommendations that was declared in WordPress site health. I found two recommendations as follows.
!
and in google search I found that this can be changed in cPanel in "select PHP version", but this feature was unavailable, I found this message ""PHP Selector is not available. Please, contact your hoster."
Than I installed plugin that solved my problem.
One of google search I found to add php.ini file in database and put following codes.
For PHP.INI file
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
OR
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 400M
file_uploads = On
max_execution_time = 180
But after creating this file hosting service put in suspension for sometime. So, is there any safe method to increase upload file size of galary.
Where is current defined file size by hosting service?
You can easily increase the size limits by adding the following lines of code in the functions.php file of your theme.
However, remember if you change the theme then max upload size will return to its default values until you edit the functions.php file of the new theme.
#ini_set( 'upload_max_size' , '64M' );
#ini_set( 'post_max_size', '64M');
#ini_set( 'max_execution_time', '300' );
php.ini Option
upload_max_filesize = 25M
post_max_size = 13M
memory_limit = 15M
Or you can do from wp-config.php File
Open the file in any text editor and add the following code.
#ini_set( 'upload_max_size' , '20M' );
#ini_set( 'post_max_size', '13M');
#ini_set( 'memory_limit', '15M' );
I'm using opencart 3.0.2 and when i change twig files it doesn't appear on site for example there is a code like this:
<div class="compare">
<button type="button" title="{{ button_compare }}" onclick="compare.add('{{ product.product_id }}');"<span>{{ button_compare }}</span></button>
</div>
and I delete this code from file but it doesn't make any change on the site.
the html part looks like this:
...
<form action="/upload/select-single/" method="post" enctype="multipart/form-data">
<input type="hidden" name="csrfmiddlewaretoken" value="U3Uh3EAYWXaWEiNaWC3zcCQutQe8hGM53u4BTx810o08t1GwOfIJI2ayHCFQFySw">
<p>
<label for="id_file_field">File field:</label>
<input id="id_file_field" name="file_field" type="file" multiple="" required="">
</p>
<input id="submit" type="submit" value="submit">
</form>
...
the selenium test like this:
...
btn_choose_file = self.browser.find_element_by_id("id_file_field")
# write file path to field
# to check that I really selected the field, I tried btn_choose_file.click() -> and it works
btn_choose_file.send_keys('/path/to/file') # -> THIS is the line which seems to cause the problem
# click submit
self.browser.find_element_by_id("submit").click()
...
unfortunately when the test is executed this error is raised
selenium.common.exceptions.WebDriverException: Message: File not found: /path/to/file
this due to the part where the file path is send to the input element with btn_choose_file.send_keys('/path/to/file')
note: the real '/path/to/file' is the following
/Users/udos/development/trails/processfile/gpx_data/test_data/suite 001 - val poschiavo/Bernina - Le Prese.gpx (the file exists and I copied the path from the IDE)
very odd behaviour. this test was running before, somehow I managed to break it...
any suggestions what the cause could be?
UPDATE downgrading Firefox from version 55.0.2 to 54.0.1 "fixed" the issue.see -> https://stackoverflow.com/a/45753912/420953
One way to work around the issue is to replace all "/" occurances in the filename with "\" ("\\" in python).
This work at least on Windows.
After this bug i installed and used chromewebdriver. Worked like firefox driver and all my tests run smoothly. I suggest you try it at least it worked like a charm for me
this error was due to an update of Firefox to version 55.0.2 (which automatically happened 2 days ago because I have automatic updates configured)
the following geckodriver issue pointed me into this direction
https://github.com/mozilla/geckodriver/issues/659note: probably this issue was reintroduced in 55.0.x...
I then downgraded my Firefox version to 54.0.1 as described in article
https://support.mozilla.org/en-US/kb/install-older-version-of-firefoxnote: make sure to disable automatic updates as described in that article.
with this, the selenium tests are running again.
I am trying to load test my nodejs app using loadtest module.My app accepts a json from a form and parse it.The form looks like
<form action="http://localhost:8081/json"
method="post" >
<label>
Copy paste json
</label>
<textarea name="json" required cols="30" rows="5"></textarea>
<input type="submit" name="submit" ,id="submit">
Problem: When i try to loadtest this using the argument as below
loadtest.js -c 10 --rps 200 -P '{"json":"{"employees":[{"firstName":"John", "lastName":"Doe"},{"firstName":"Anna", "lastName":"Smith"},{"firstName":"Peter", "lastName":"Jones"}]}"}' -T 'application/x-www-form-urlencoded' -m POST http://localhost:8081/json
i am getting
req.body.json
as
undefined
A sample json that i expect is
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}]}
I have googled and tried the documentations but i just cant get it fixed.
Please help and thanks in advance
I use TYPO3 CMS 6.2.14, vhs 2.3.3, Flux 7.2.1 and FluidContent 4.3.1 - my TYPO3 Editor need the opportunity to upload SVG-Images via vhs-ViewHelper. I've made a new FluidTYPO3 Content Element (FCE), but there's no SVG Image visible in frontend. Mmhh?
Flux-FlexForm
<flux:field.file name="imgIcon" allowed="jpg,gif,png,jpeg,svg" uploadFolder="uploads/tx_myext" minItems="0" maxItems="1" size="1" />
...
<v:media.image src="uploads/tx_myext/{imgIcon}" alt="Icon" />
Output
<div class="small-2 columns">
<img alt="Icon" src="" width="" height="">
</div>
Also I use the htaccess entry, but there is no success. Where's my fault? Do I need heightand widthfor this ViewHelper? Aren't vectors availible in vhs?
<IfModule mod_mime.c>
...
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
...
</Ifmodule>
EDIT: I also tried the Fluid ViewHelper, but the SVG Image has height/width = 0:
<f:image src="uploads/tx_myext/{imgIcon}" width="50" height="50" class="xy" alt="Icon" />
EDIT 2: The ImagePath is correct. At Developer Tools I "see" the Image ..
EDIT 3: Oh, I see at my Filemanager (FAL) 0x0 pixels ..
Thanks merec.
Use SVG Images / TYPO3 6.2 with FluidTYPO3
Answer: Use
<img src="{f:uri.image(src: 'uploads/tx_myext/{imgIcon}')}">
instead of
<v:media.image src="uploads/tx_myext/{imgIcon}" alt="Icon" />
// OR
<f:image src="uploads/tx_myext/{imgIcon}" width="50" height="50" class="xy" alt="Icon" />