PhpRealestateScript - Tin tức nhanh - mới - nóng nhất đang diễn ra
  • Home
  • Phần Mềm
  • Công Nghệ
  • Kinh Doanh
No Result
View All Result
  • Home
  • Phần Mềm
  • Công Nghệ
  • Kinh Doanh
No Result
View All Result
PhpRealestateScript - Tin tức nhanh - mới - nóng nhất đang diễn ra
No Result
View All Result

PHP Multiple File Uploading

admin by admin
March 10, 2020
in Lập Trình PHP
25
PHP Multiple File Uploading



Want more? Explore the library at Official site Twitter

Nguồn:https://phprealestatescript.com/

Xem thêm Bài Viết:

  • Top 4 phần mềm lập trình C++ tốt nhất hiện nay
  • Tự học lập trình web bắt đầu từ đâu? – Bật mí chi tiết lộ trình “chuẩn” cho người mới học
  • Giải đáp thắc mắc: Trong nhiếp ảnh và đồ họa manipulate là gì?
  • Bài viết: Bật mí lộ trình học lập trình Web hiệu quả nhất hiện nay
  • Giải thích khái niệm và ý nghĩa của thuật toán nổi bọt
Tags: Youtube
Previous Post

Cuộc sống là vậy, chân thành và thật thì dễ sống nhất, Ngân 98 - Lương Bằng Quang

Next Post

Fan Zhendong vs Wang Chuqin | 2020 ITTF Qatar Open Highlights (1/2)

Next Post
Fan Zhendong vs Wang Chuqin | 2020 ITTF Qatar Open Highlights (1/2)

Fan Zhendong vs Wang Chuqin | 2020 ITTF Qatar Open Highlights (1/2)

Comments 25

  1. Mansi Kriplani says:
    2 years ago

    you are just awesome.easiest code

    Reply
  2. Jinal Kothari says:
    2 years ago

    hey i want to insert data from each file additional to this. But I am unable to do this. Please help me doing this.

    Reply
  3. David Connelly says:
    2 years ago

    Nicet tutorial – and I love the idea of using pure PHP, instead of some framework. However, I think the structure with all those nested IFs is a bit of a shame. In any event, thanks for that. It was good.

    Reply
  4. Himank Pandya says:
    2 years ago

    this code is wrong, it is not working

    Reply
  5. Martijn Schuman says:
    2 years ago

    Parse error: syntax error, unexpected ';' in C:wamp64wwwuploadupload.php on line 35
    plz help

    Reply
  6. arne vanoerle says:
    2 years ago

    instead of a confusing foreach() loop, i just made a for() loop like this:

    <?php

    if (!empty($_FILES['image']['name'][0])) {

    $imageAmount = count($_FILES['image']['name']);

    for ($i=0; $i < $imageAmount; $i++) {

    $imgName = $_FILES['image']['name'][$i];
    $imgTempLoc = $_FILES['image']['tmp_name'][$i];
    $imgSize = $_FILES['image']['size'][$i];
    $imgError = $_FILES['image']['error'][$i];

    $imgExt = explode('.', $imgName);
    $ActualImgExtention = strtolower(end($imgExt));

    $allowed = array('jpg', 'jpeg', 'tiff', 'png');

    if (!in_array($ActualImgExtention, $allowed)) {
    echo 'You cannot upload files of type: ' . end($imgExt);
    }else{
    if (!$imgError === 0) {
    echo 'There was een error uploading your image!';
    }else{

    $NewImgName = uniqid('', true);
    $ImgDestination = '../uploads/' . $NewImgName . "." . $ActualImgExtention;
    if(move_uploaded_file($imgTempLoc, $ImgDestination)){
    header("Location: ../index.php?upload=succes");
    }else{
    header("Location: ../index.php?upload=failed");
    }
    }
    }
    }
    }else{
    header("Location: ../index.php?cheeter");
    exit();
    }

    Reply
  7. dedeque 22 says:
    2 years ago

    mcm mana nak set file tu, dlm bhsa melayu pun xfhm steps nya

    Reply
  8. Robin 007 says:
    2 years ago

    Thank You

    Reply
  9. Gen Ji says:
    2 years ago

    Do you have a tutorial about downloading the uploaded file??

    Reply
  10. NikelaasK says:
    2 years ago

    foreach function doesn't return array for me. print_r($file_ext); gives me jpgjpgjpg

    Reply
  11. hank barzs says:
    2 years ago

    thanks a lot bruv

    Reply
  12. Deepak Mohapatra says:
    2 years ago

    upload with 2 or more image upload control with one submit button in to one table only
    how to do that

    Reply
  13. René E. Mejía says:
    2 years ago

    This is amazing.

    Reply
  14. Luke Watts says:
    2 years ago

    I think it's easier to simply make a proper array first.

    $n = count($_FILES['files']['name']);
    $files = [];
    for ($i = 0; $n > $i; $i++) {
    $files[$i]['name'] = $_FILES['files']['name'][$i];
    $files[$i]['type'] = $_FILES['files']['type'][$i];
    $files[$i]['tmp_name'] = $_FILES['files']['tmp_name'][$i];
    $files[$i]['error'] = $_FILES['files']['error'][$i];
    $files[$i]['size'] = $_FILES['files']['size'][$i];
    }

    For two files gives you an array:

    $files = [
    0 => [
    'name' => 'image01.jpg',
    'type' => 'image/jpeg',
    'tmp_name' => 'tmp01.tmp',
    'error' => 0,
    'size' => 2048
    ],
    1 => [
    'name' => 'image02.jpg',
    'type' => 'image/jpeg',
    'tmp_name' => 'tmp02.tmp',
    'error' => 0,
    'size' => 1024
    ]
    ];

    Which is much easier to deal with then. Then you can use the exact same logic as for one file…but in an "foreach" loop.

    Usually Alex and the gang are very good at simplifying the task but this seemed to be unnecessarily complex.

    Reply
  15. Grant Davis says:
    2 years ago

    This is a confusing example too much jumping backwards and forward that it almost seems to be intentionally showing off and confusion intended. Sorry but this good coding sucks because it is not straight forward knowledge.

    Reply
  16. Rajini R Gowda says:
    2 years ago

    Hi…. Am not able to upload more than 4 Images so is their any solution?

    Reply
  17. Jonathan Davies says:
    2 years ago

    Great, it's working perfectly! Any idea how to delete an image?

    Reply
  18. Kashish Aggarwal says:
    2 years ago

    Hi, Thanks for the video. However, I am trying to upload some files using the same logic but I couldnt do so. I placed echo statements at different places to debug my code and figured out that the control is not entering 'foreach' loop. Could you please help?

    Reply
  19. arendzen says:
    2 years ago

    Brilliant – thanks. Only thing that would have made it totally perfect is to know how to return a success or fail message that doesn't have words like 'array' which nobody really understands

    Reply
  20. Bulag na Bandido says:
    2 years ago

    it says completed but no files in the directory.. how to fix that??

    Reply
  21. Bulag na Bandido says:
    2 years ago

    how do I trigger the upload without clicking the upload button??

    Reply
  22. Berten Bevers says:
    2 years ago

    I used this code to upload Images to my website, but for some reason this code doesn't let me upload more than 20 Images. If i try to upload 35 Images, 15 will be dropped.

    Reply
  23. Alex Berea says:
    2 years ago

    on some files larger than 2mb not show me any error or message. 
    the weird part is that the files are not uploaded.
    simply do nothing.
    I am very confused

    Reply
  24. saksham chauhan says:
    2 years ago

    Nice tutorial. Which macbook do you use, anyway? Please tell me the specs I am also considering on buying a macbook.

    Reply
  25. Rahul Giri says:
    2 years ago

    very nice .

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Xem Thêm

Máy hút chân không 2 buồng phù hợp với cơ sở chế biến nào?

Máy hút chân không 2 buồng phù hợp với cơ sở chế biến nào?

August 9, 2022
Xe điện phát triển nhanh hơn tốc độ xây dựng trạm sạc công cộng khiến cung cầu bị mất cân bằng (Nguồn: Sưu tầm)

Năm 2030 thị trường trạm sạc xe điện thế giới chạm mốc 823 tỷ USD 

July 28, 2022
Bộ đồ thờ gốm Bát Tràng cao cấp men vàng 24k dành cho giới thượng lưu gồm 25 món cầu kỳ 

Chọn bộ đồ thờ theo mức giá như thế nào để đảm bảo chất lượng lẫn phong thuỷ?

June 16, 2022
kệ rượu vĩ công mang vẻ đẹp sang trọng, thời thượng

Top 3 kệ rượu vang sang trọng, đẳng cấp nhất năm 2022

May 13, 2022
Ưu/ nhược điểm của đá ốp bếp nhân tạo và tự nhiên

Giải đáp thắc mắc: Nên lựa chọn đá ốp bếp nhân tạo hay tự nhiên?

February 16, 2022
Một số đầu sim dễ nhớ tại simdeponline

Sim dễ nhớ tìm mua và tham khảo ở đâu giá rẻ nhất?

January 18, 2022
  • Giới Thiệu
  • Liên Hệ
  • Chính Sách Bảo Mật

© 2022 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Phần Mềm
  • Công Nghệ
  • Kinh Doanh

© 2022 JNews - Premium WordPress news & magazine theme by Jegtheme.