In my form I have 3 input fields for file upload:
<input type=file name="cover_image">
<input type=file name="image1">
<input type=file name="image2">
How can I check if cover_image
is empty - no file is put for upload?
In my form I have 3 input fields for file upload:
<input type=file name="cover_image">
<input type=file name="image1">
<input type=file name="image2">
How can I check if cover_image
is empty - no file is put for upload?
Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):
$ pecl -d php_suffix=5.6 install <package>
$ pecl uninstall -r <package>
$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>
$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>
The -d php_suffix=<version>
piece allows you to set config values at run time vs pre-setting them with pecl config-set
. The uninstall -r
bit does not actually uninstall it (from the docs):
vagrant@homestead:~$ pecl help uninstall
pecl uninstall [options] [channel/]<package> ...
Uninstalls one or more PEAR packages. More than one package may be
specified at once. Prefix with channel name to uninstall from a
channel not in your default channel (pecl.php.net)
Options:
...
-r, --register-only
do not remove files, only register the packages as not installed
...
The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).
See the sample I have created:
http://jsfiddle.net/G7xke/
<form>
<input type="file" name="files" id="file1" style="color:White" />
<input type="submit" value="Create" />
</form>
<button value="check" id="check" name="check" >check</button>
And JavaScript:
$("#check").click(function(){
var fileName = $("#file1").val();
if(fileName.lastIndexOf("png")===fileName.length-3)
alert("OK");
else
alert("Not PNG");
})
That's not an associative array, it's a regular array, but the answer is the same. Use .Count
and compare to 0.
An associative array is called a [hashtable]
in PowerShell and its literal form uses @{}
(curly braces).
@{}.Count -eq 0 # hashtable (associative array)
@().Count -eq 0 # array
Never used any of those, but they look interesting..
Take a look at Gearman as well.. more overhead in systems like these but you get other cool stuff :) Guess it depends on your needs ..
You can check by using the
size
field on the$_FILES
array like so:(I also check
error
here because it may be0
if something went wrong. I wouldn't usename
for this check since that can be overridden)