51: Upload Files and Images to Website in PHP | PHP Tutorial | Learn PHP Programming | Image Upload



Upload Files and Images to Website in PHP | PHP Tutorial | Learn PHP Programming | Image Upload. In this PHP tutorial I will show how to easily upload images and files to a website using PHP.

We will also learn how to add error handlers specific to uploading such as file size and file type.

➤ GET ACCESS TO MY LESSON MATERIAL HERE!

First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!

I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.

I hope you will find it helpful 🙂

Material for this lesson:

Nguồn: https://svdpch.org/

Xem thêm bài viết khác: https://svdpch.org/cong-nghe/

28 thoughts on “51: Upload Files and Images to Website in PHP | PHP Tutorial | Learn PHP Programming | Image Upload”

  1. Great Video !!
    If anyone is facing an issue where files are not seen in uploads folder on a Mac then go to uploads folder , right click ->get info and set permissions to read and write

    Reply
  2. Shouldn't you also get the current directory and us it as beginning of path in $fileDestination variable? In my case it didn't work without this.

    Reply
  3. [For Linux users] ::: If you are having trouble transferring the uploaded file to the uploads folder execute the following in terminal (using superuser privileges if necessary)
    $ chmod 777 some_path/uploads

    Reply
  4. Anyone else having trouble with the triple "=". Needed to switch to a double "=" to avoid error code 1.

    Reply
  5. <?php
    if(isset($_POST['submit'])){
    $file= $_FILES['File'];
    $File_name=$_FILES['File']['name'];
    $File_tmp=$_FILES['File']['tmp_name'];
    $File_type=$_FILES['File']['type'];
    $File_size=$_FILES['File']['size'];
    $File_error=$_FILES['File']['error'];
    $File_ext_arr=explode('.',$File_name);
    $File_ext=strtolower(end($File_ext_arr));
    $allowed_Ext=array('jpg','jpeg','png','pdf');
    if($File_ext<>""){
    if(in_array($File_ext,$allowed_Ext)){
    if($File_error==0){
    if($File_size<=500000){
    $File_name_new= uniqid('Me',true).".".$File_ext;
    $File_des='helow/'.$File_name_new;
    move_uploaded_file($File_tmp,$File_des);
    header("location:lesson51.php?=uploaded succ");
    }else{
    echo"The file is bigger than standers";
    }
    }else{
    echo"You have an error uploding your File";
    }
    }else{
    echo"Your File Not Allowed";
    }
    }else{
    echo"you didn't select an image ";
    }
    }

    Reply
  6. By far the best tutorial out there! Thank you so much for sharing this knowledge in a comprehensive, easy-to-follow lesson! You, my good sir, just got a new subscriber and a very high recommendation!

    Reply
  7. Thanks for the video.

    I just have one issue though. This method works perfect when I'm browsing my site using a pc. But it outputs an error message when I;m using a mobile device saying "Unable to complete previous operation due to low memory". Only on a mobile device.

    Reply
  8. I so love the way you teach. I will become a patron soon as I find a job, I promise you!! I'm learning so much with you. Thank you so very much; I so deeply appreciate your excellent tutorials.

    Reply
  9. i get this message
    Notice: Undefined index: file in /opt/lampp/htdocs/upload.php on line 3

    Notice: Undefined index: file in /opt/lampp/htdocs/upload.php on line 5

    Notice: Undefined index: file in /opt/lampp/htdocs/upload.php on line 6

    Notice: Undefined index: file in /opt/lampp/htdocs/upload.php on line 7

    Notice: Undefined index: file in /opt/lampp/htdocs/upload.php on line 8

    Notice: Undefined index: file in /opt/lampp/htdocs/upload.php on line 9
    you cannot upload this file type

    Reply

Leave a Comment