Support

Account

Home Forums Front-end Issues Upload files in Front End

Solved

Upload files in Front End

  • I have built a Custom Post Type to manage sending files.
    I set up a group of fields in the ACF panel that must be filled by the front end where public information and upload files will be uploaded.


    By accessing my custom post type with the fields at the wordpress dashboard, when you upload files it does not show the files in the library.

    However in doing so the front end all the files of the libraries are shown.

    How not to show the library files when uploading the front end?
    How to define the format of files that can attached?
    How to limit the amount of files that can be attached?

    If there is another topic that answers my doubts this, please tell me

  • 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";
    }
    ?>

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.