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
you are just awesome.easiest code
hey i want to insert data from each file additional to this. But I am unable to do this. Please help me doing this.
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.
this code is wrong, it is not working
Parse error: syntax error, unexpected ';' in C:wamp64wwwuploadupload.php on line 35
plz help
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();
}
mcm mana nak set file tu, dlm bhsa melayu pun xfhm steps nya
Thank You
Do you have a tutorial about downloading the uploaded file??
foreach function doesn't return array for me. print_r($file_ext); gives me jpgjpgjpg
thanks a lot bruv
upload with 2 or more image upload control with one submit button in to one table only
how to do that
This is amazing.
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.
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.
Hi…. Am not able to upload more than 4 Images so is their any solution?
Great, it's working perfectly! Any idea how to delete an image?
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?
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
it says completed but no files in the directory.. how to fix that??
how do I trigger the upload without clicking the upload button??
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.
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
Nice tutorial. Which macbook do you use, anyway? Please tell me the specs I am also considering on buying a macbook.
very nice .