Support

Account

Home Forums Front-end Issues Upload files in Front End Reply To: Upload files in Front End

  • hi

    have you tried some code pls share I will suggest you change it seems all of your requirements are related PHP coding

    If your requirements are limited to following only

    How not to show the library files when uploading the front end?
    1) create html form to upload image
    http://www.kvcodes.com/2013/12/create-front-end-multiple-file-upload-wordpress/

    2) How to define the format of files that can attached?
    Refer following code here u can limit type file to be uploaded
    3) How to limit the amount of files that can be attached?
    by following code u can limit the size of file

    <?php
    $allowedExts = array(“gif”, “jpeg”, “jpg”, “png”);
    $temp = explode(“.”, $_FILES[“file”][“name”]);
    $extension = end($temp);

    if ((($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/jpeg")
    || ($_FILES["file"]["type"] == "image/jpg")
    || ($_FILES["file"]["type"] == "image/pjpeg")
    || ($_FILES["file"]["type"] == "image/x-png")
    || ($_FILES["file"]["type"] == "image/png"))
    && ($_FILES["file"]["size"] < 20000)
    && in_array($extension, $allowedExts)) {
    if ($_FILES["file"]["error"] > 0) {
    echo "Error: " . $_FILES["file"]["error"] . "<br>";
    } else {
    echo "Upload: " . $_FILES["file"]["name"] . "<br>";
    echo "Type: " . $_FILES["file"]["type"] . "<br>";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
    echo "Stored in: " . $_FILES["file"]["tmp_name"];
    }
    } else {
    echo "Invalid file";
    }
    ?>