Asked  7 Months ago    Answers:  5   Viewed   38 times

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?



You can check by using the size field on the $_FILES array like so:

if ($_FILES['cover_image']['size'] == 0 && $_FILES['cover_image']['error'] == 0)
    // cover_image is empty (and not an error)

(I also check error here because it may be 0 if something went wrong. I wouldn't use name for this check since that can be overridden)

Wednesday, March 31, 2021
answered 7 Months ago

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario:

Related usability ticket:

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
answered 7 Months ago

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
answered 5 Months ago

Quite simple:

<input ng-model="somefield">
<span ng-show="!somefield.length">Please enter something!</span>
<span ng-show="somefield.length">Good boy!</span>

You could also use ng-hide="somefield.length" instead of ng-show="!somefield.length" if that reads more naturally for you.

A better alternative might be to really take advantage of the form abilities of Angular:

<form name="myform">
  <input name="myfield" ng-model="somefield" ng-minlength="5" required>
  <span ng-show="myform.myfield.$error.required">Please enter something!</span>
  <span ng-show="!myform.myfield.$error.required">Good boy!</span>

Updated Plnkr here.

Wednesday, July 28, 2021
answered 3 Months ago

See the sample I have created:

<input type="file" name="files" id="file1" style="color:White" />
<input type="submit" value="Create" />
<button value="check" id="check" name="check" >check</button>

And JavaScript:

    var fileName = $("#file1").val();
        alert("Not PNG");
Sunday, September 19, 2021
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :