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

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024

Комментарии • 1,1 тыс.

  • @amitrokade1140
    @amitrokade1140 6 лет назад +194

    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

    • @Dani_Krossing
      @Dani_Krossing  6 лет назад +34

      I'll just go ahead and pin this comment for others to see :) and thank you for sharing, I don't use Mac so I wouldn't have been able to figure this out.

    • @amitrokade1140
      @amitrokade1140 6 лет назад

      Welcome :)

    • @Stephlovesummer
      @Stephlovesummer 6 лет назад +7

      You just saved my life

    • @nillsinrodrigues7533
      @nillsinrodrigues7533 6 лет назад

      .

    • @balamurugans5845
      @balamurugans5845 6 лет назад +12

      I am facing an issue like when I click upload button it's going to upload.php. But the file is not in uploads folder and there is no any successful msg. Please hlp me

  • @coookiessssss
    @coookiessssss 4 года назад

    thank you! I have been struggling with this for three days. Followed your video and it works ! (No idea why)

  • @vergilkelley5078
    @vergilkelley5078 3 года назад +35

    Thanks to content providers like you I have a new career as a web developer at the ripe age of 54 lol. Can't thank you enough for all the free content and flawless delivery. Your channel is truly amazing and inspiring!

    • @waqarahmad7125
      @waqarahmad7125 2 года назад +1

      thats amazing

    • @chessmasterstream8953
      @chessmasterstream8953 Год назад +1

      I'm 29 and moving in same direction. After an injury im changing my carreer. And seeing you at this age i think i can do it as well. Just a lot of stuff to learn. Scary.

    • @XxxclusiveReviews
      @XxxclusiveReviews Год назад

      I had some young chump female ask why I want to do IT.... LIKE I DONT BELONG HERE... this witch needs to know started before she could suck on a baby bottle.... now I'm knee deep... and learning it all... once done I will be a full stack... I'm now I'm a honor student... stfu brat

  • @ricardoalsoa
    @ricardoalsoa 4 года назад

    Always good videos. I'm learning too much with you. Gratitude to share your knowledge.

  • @ayeshaimtiaz4557
    @ayeshaimtiaz4557 2 года назад

    I LOVED THIS VIDEO.....THANKU SO MUCH

  • @marcohama1
    @marcohama1 5 лет назад

    very good, thank you!

  • @Sumyyassan7044
    @Sumyyassan7044 2 года назад

    Hi pls can u help us or recommend any tutorial on how to design and implement remote control using php

  • @henrycodingstack6952
    @henrycodingstack6952 7 лет назад

    thanks nice video.but how do you create a download script for files uploaded,and how do you display the files uploaded by users on your index.php page?

  • @mourshiedshoshy
    @mourshiedshoshy 5 лет назад

    Thanks

  • @francismata4492
    @francismata4492 6 лет назад

    Sir can you do a tutorial on how to make a quiz with images as part of questions. Thanks in advance.

  • @parthivnaik9141
    @parthivnaik9141 7 лет назад

    which function can be used to get the contents before ' . ' ( I mean as 'end' function gets content after the dot(.) , which function gets contents before the dot( . ) ?) Waiting for your reply.

    • @e8mile
      @e8mile 6 лет назад

      reset()

  • @bintoygaming
    @bintoygaming 6 лет назад

    God Bless you Sir =)

  • @DavisTibbz
    @DavisTibbz 3 года назад +10

    Hmmm....that nested "if" block (from line 16) looks frightening ... A cleaner alternative is to use single-line, independent, "if . . . " statements with "exit("error message") if given condition is FALSE. See his modified example below:
    if ($fileSize > MAXLIMIT ) exit("File is too large."); //Replace MAXLIMIT with an integer value.
    if ($fileError !==0) exit ("Error occurred. Upload failed");
    if(in_array($fileActualExt, $allowed)) === FALSE) exit("File type not allowed");
    else {
    // everything is OK
    //... Continue with your code, as shown in video, from line 19-22
    //..
    }

    • @quatricise
      @quatricise 3 года назад

      Yes, I was thinking the same but had no idea how to refactor it. Thanks, i didnt know about the exit()

    • @martinrombach2666
      @martinrombach2666 2 года назад +1

      True. That's pretty ugly ass code.

  • @issuefixer3386
    @issuefixer3386 2 года назад +2

    How can we block the user from uploading image which has more than 250px of height and more than 250px of width? Can anyone please help me about this? Thank you.

  • @sebspokestop
    @sebspokestop 7 лет назад +20

    Flawless delivery - this was absolutely outstanding, I cannot thank you enough!

  • @thasan4509
    @thasan4509 7 лет назад +15

    for developers: never trust what user sends, questionable everything what user sends.
    On this video its not problem, but what if user sends file with name ".jpg" to your script, or "../index.php" or "index.php
    .jpg" (
    means newline character)
    if you use blacklist to disallow some file extensions uploads, check what extensions are executable on server config; What if someone uploads "innocentfile.phtml"? (yes, phtml is executable on default apache2+php setup)

    • @Scott-zi7xv
      @Scott-zi7xv 7 лет назад

      It'll work.

    • @slapmyfunkybass
      @slapmyfunkybass 6 лет назад +2

      This doesn’t make any sense, though hackers can upload executables then run it on the server (technically they couldn’t because they wouldn’t have permissions) the file name here is renamed and the extension is checked for. On top of that you have pointed the file to a location on the server so it won’t go anywhere else. The method shown here is fine in real world production.

    • @ghaliaalkulaibi1855
      @ghaliaalkulaibi1855 6 лет назад +1

      but he used the whitelist filtering which is better than the blacklist .. so .phtml will not be accepted because it's not allowed

    • @sandortoth5269
      @sandortoth5269 5 лет назад +3

      For a beginner tutorial, this is alright.
      But Thasan is right, for a production website, you must implement solutions against potential hacker attacks.
      Let's say i have a png image and i replace the extension from "png" to "gif".
      That doesn't make my png image being a gif image.
      The image is still a png image, because the name of any file (including extension) doesn't tell anything of the file.
      Therefor you must check the header of the uploaded image.
      Hint: check out this php function: exif_imagetype

  • @akashgola2153
    @akashgola2153 6 месяцев назад +2

    Another Great Upload even though it's from past hehe. Also i am noticing that in this videos ur doing quite a bit of nesting which u clearly said isn't a very good thing to do in ur recent uploads . Now i can actually see why. keep updating us

  • @Cocinaconparrilla
    @Cocinaconparrilla 5 лет назад +3

    Non-PHP-Programmers: PHP SUCKS!
    *But they watched this video to see how to create a File Uploader in PHP And they still Complain that PHP Sucks. (320K views and very sure most of the viewers have talked negatively about PHP)

  • @alainperez8579
    @alainperez8579 5 лет назад +21

    This has been the best PHP tutorial I have ever watched. Thank you

  • @egetomaitelope3854
    @egetomaitelope3854 2 года назад +2

    How can I preview the image before UPLOAD

  • @alexanderuranbirkin3379
    @alexanderuranbirkin3379 7 лет назад +14

    Daniel thank you very much!

  • @karunakarans4296
    @karunakarans4296 2 года назад +1

    7:26
    Parse error :syntax error, unexpected token " ) " , expecting variable or "{" Or "$" In C:\Users\ELCOT\Desktop\setup xampp\htdocs\php_program\upload.php on line 4
    (Line 4 in upload.php is👉👉👉print_r($)
    What does it mean 😶.. I'm begginer.. What I should do now bro!?

  • @DsNHira
    @DsNHira 3 года назад +5

    The topic is hard for a new php coder like me. But the entire video is well explained with a great detail. I think I couldn't learn and do in a proper way without your nice tutorial. Love and respect.

  • @starbloods0013
    @starbloods0013 2 года назад +1

    Hi,
    The code works but only for files of size 2mb and less (I increased the size limit from 1000000 to 1000000000) I keep gettin a "There was an error uploading" error from the code
    Any solutions??

  • @aklenablmasry
    @aklenablmasry 6 лет назад +30

    honestly this is my first time ever to comment on youtube video so i want to thank you for the best easy to understand ever for file uploading thanks!

  • @jaivermateus554
    @jaivermateus554 Год назад +1

    thanks for the content it's really useful, but i have one question, what happens if i dont use the "$allowed"? my system will allow all kind of files? and if want to add another extension like for example .pkt , I just have to add it to the allowed array? hope someone can help me with this

  • @minegamer369
    @minegamer369 4 года назад +4

    I don’t think your gonna answer this but how do I prevent a image based attack when users upload photos when users embed code on it how do I prevent it from running

    • @AliciaGuitar
      @AliciaGuitar 4 года назад

      I'm pretty well convinced there is no way to completely secure php uploads. Found a decent article on stackoverflow stackoverflow.com/questions/38509334/full-secure-image-upload-script#

  • @ben-q2d
    @ben-q2d 4 года назад +1

    To check the file type, is there any reason why you can't just use the provided data from the form? (in this example $filetype)

  • @shevitza
    @shevitza 7 лет назад +16

    Very usefull tutorial, thanks!

  • @curtturdle5661
    @curtturdle5661 7 лет назад +10

    this is missing information, like changing folder permissions to allow uploads

    • @bishoy437
      @bishoy437 7 лет назад

      How to change these permissions on linux?

    • @bodake2557
      @bodake2557 7 лет назад

      on your own box or on a hosting service?

    • @ben_jammin242
      @ben_jammin242 6 лет назад

      Curt Turdle just the one thing really :)

  • @mjosteam2098
    @mjosteam2098 3 года назад +1

    Best Tutorial!!
    I recommend watching this channel!

    • @mjosteam2098
      @mjosteam2098 3 года назад

      Hello Dani, Thanks for your Heart!!
      i subscribed to your Channel

  • @SketchyzGaming
    @SketchyzGaming 7 лет назад +6

    When will the next PHP tutorial arrive? Could really use some knowledge on how to create profile pages, specific data/descriptions/profile pictures etc. for specific users :) It would help a lot!

    • @Dani_Krossing
      @Dani_Krossing  7 лет назад +6

      I got a bit behind todays episode because of other plans, but I am planning on recording and uploading an episode today on creating profile images for users :)

  • @Cliffhouse97
    @Cliffhouse97 2 года назад +3

    Dani, this has been a very helpful tutorial that I've used in a project I'm working on. It works wonderfully. However, in addition to uploading a file to a separate folder in my root directory , I'd like to be able to insert the file path of the uploaded file into a table I've created into a mysql database. I'm struggling to sort out how to code that into my php file.

    • @thaotruong7035
      @thaotruong7035 2 года назад

      hello sir, may you help me with this trouble, i'm trying to upload my image files into my website image folder, how can I connect it?
      thank you in advance

  • @ritamjha6080
    @ritamjha6080 7 лет назад +6

    very helpful vedio..nice step by step description Thankyou!! and please create a vedio on " how to upload vedio through a web page in database or some folder" including back end programming.

    • @xtordngy
      @xtordngy 5 лет назад

      Backend programming like a dashboard

  • @wendysturd
    @wendysturd 5 лет назад +1

    This page isn’t working feedmememes.000webhostapp.com is currently unable to handle this request.
    HTTP ERROR 500
    This is what I got when it is uploaded to my dns.

    • @maniacgear7258
      @maniacgear7258 3 года назад

      Hi there, I recommend going through the final code part by part and remove each line with CTRL + / when highlighted, then view this in xxamp or mamp and carry on trying until the error disappears. This is what worked for me, and if it works for you let me now. Sorry for a 1 year late reply, hope I'm still helping!

  • @diviiniity6529
    @diviiniity6529 7 лет назад +6

    These tutorials are amazing, I used to only do HTML and code boring website, but know thanks to you, I can do all of these fun stuff! Thanks! Keep up the good work

    • @thaotruong7035
      @thaotruong7035 2 года назад

      hello sir, may you help me with this trouble, i'm trying to upload my image files into my website image folder, how can I connect it?
      thank you in advance

  • @donatkalman2636
    @donatkalman2636 4 года назад +1

    Can you do this with dropbox or google drive?

  • @nanayeboah3287
    @nanayeboah3287 3 года назад +3

    Why am I just discovering this channel? Been searching for tutors like this. He explains so well to my very best understanding.

  • @tahaazhari3369
    @tahaazhari3369 4 года назад +1

    i am unable to see the images in my folder but it is displaying upload successes in my URL i use windows OS (10 Pro)

  • @daniellajohansson
    @daniellajohansson 7 лет назад +5

    Just a shout out to the Ubuntu people. If you get uploadsuccess but no img in the folder...check your rights.

    • @keeper31796
      @keeper31796 7 лет назад +1

      THANK YOU SO MUCH. I have been trying to figure out why this wasn't working for like 2 hours.

    • @curtis4621
      @curtis4621 7 лет назад

      how did you go abt it

    • @keeper31796
      @keeper31796 7 лет назад +2

      ls -la on the folder it is uploading to. The output will be something along the lines of drwxr-wr-w most likely, this means it is a directory (d) the owner of the file has read (r), write (w) and execute (x) permissions. then you will see a number next to that, then the owner of the folder/file. If the owner is not PHP or something similar you can change the owner or change the permissions, changing permissions can be done like so, "chmod 775 ". You may need to use 777 instead of 775 but be aware that this means that anything that can gain access to that folder will have read, write, and execute access.
      If you have more questions let me know.

    • @curtis4621
      @curtis4621 7 лет назад

      thanks... however the uploaded files won't show even after changing permissions, what could be wrong??

    • @keeper31796
      @keeper31796 7 лет назад

      what is the output from ls -la on that folder

  • @sudosai
    @sudosai 4 года назад +2

    [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

    • @smk751
      @smk751 2 года назад

      Thanks for this and thanks for the tutorial, but have done this and it still doesn't work

  • @mladenmladenov7835
    @mladenmladenov7835 7 лет назад +3

    Thanks for this episode, very good series as well! Thank you!

  • @Wiroue
    @Wiroue 5 лет назад

    If you have problem and cant upload the image to folder and you are using linux, you most likely don't have permission due htdocs folder being owned by root.
    How to set permission:
    $sudo chmod -R 777 /opt/lampp/htdocs
    then give user permission:
    $sudo chown -R username:groupname /opt/lampp/htdocs
    note: to check your username and groupname use:
    $whoami
    $id -gn
    this will give you permission to upload files to folder if the files are not to big, otherwise change upload_max_size in php.ini config file

  • @fairydragonbreath9192
    @fairydragonbreath9192 7 лет назад +5

    Are you going to show how to make something like an forum page? Like how you see people make comments here in RUclips.

    • @therealice
      @therealice 7 лет назад +1

      He already showed how to create a comment section, but a forum would be cool.

    • @Dani_Krossing
      @Dani_Krossing  7 лет назад +7

      A forum page is planned for a future episode :)

    • @SoccerEFM
      @SoccerEFM 6 лет назад

      I am almost done creating my own forum in PHP/MySQL, if you follow all tutorials from mmtuts about creating a comment and login section, you can use that as a reference for creating your own forum :)
      I am so thankfull to mmtuts, im really addicted to PHP now haha

    • @yogitasinkar5979
      @yogitasinkar5979 6 лет назад

      SoccerEFM Hey, can you plz point out the videos where he covered comments?

  • @karimahussein9010
    @karimahussein9010 4 года назад +3

    can't thank you enough for this tutorial

  • @Education-x6l
    @Education-x6l 4 года назад +1

    Followed everything correctly but my files can not be uploaded to my directory folder?? please help

    • @zargonkulas9342
      @zargonkulas9342 4 года назад

      its because of the in_array function remove the condition if(!in_array($fileActualExt,$allowed)){ dont know why this function not working

  • @aghahusnain4424
    @aghahusnain4424 4 года назад +6

    Best tutorial ever. Genuinely saved me hours of time. I dont usually comment on videos, but had to based on how comprehensively the tutorial was posted. Thanks alot for posting!!

  • @shadowcowmooo7415
    @shadowcowmooo7415 2 года назад +1

    when I click the upload button, the image uploads, but i am redirected to the upload.php file, any help?

  • @danielchoo211
    @danielchoo211 7 лет назад +4

    Sorry, I still cannot upload image into uploads folder. Why?

    • @ferozahmmed7401
      @ferozahmmed7401 6 лет назад

      move_uploaded_file("folder_name/"."file_name".$extension); I think it will be worked .

    • @sofasniperman
      @sofasniperman 5 лет назад

      @@ferozahmmed7401 Don't forget the "." in between the file name and extension

    • @sofasniperman
      @sofasniperman 3 года назад

      @Visions Weekly Magazine i don't remember why I said that lol. Maybe the period was missing when I commented that and he added it in later?

  • @miquel2423
    @miquel2423 3 года назад +1

    I have a question. I don't get it how the data inside the file got moved up all the way to $fileNewName. Was the data inside the uploaded file in the $fileExtension variable? and got it moved all the way to $fileNewName? Or is the file data inside the extension?

  • @gamerunnerstaydon
    @gamerunnerstaydon 5 лет назад +3

    Thank you for sharing your knowledge! 😊

  • @oliversmith7097
    @oliversmith7097 3 года назад +1

    Just a tip: your file extension type is checking just the name of the file - it doesn't mean it's an actual image file. Instead, I would recommend using mime_content_type() to check the actual file type.
    $filetype = mime_content_type($_FILES['file']['tmp_name']);
    if(($filetype !== 'image/png' && $filetype !== 'image/jpeg')){
    die("Not a gif/jpeg/png");
    }

    • @steve905
      @steve905 2 года назад

      I was about to raise this same point.

  • @floydapungan5853
    @floydapungan5853 6 лет назад +6

    Hey man, thanks for this, But I'm having a problem, I have successfully uploaded the picture(?uploadsuccess) but one I checked the folder, it is empty, any Idea what the problem is?

    • @janeilalcano9258
      @janeilalcano9258 4 года назад

      Mine too, have you fixed the problem?

    • @garylam5353
      @garylam5353 4 года назад

      @@janeilalcano9258 same error, did you fix it?

    • @garylam5353
      @garylam5353 4 года назад

      @@janeilalcano9258 same error, did you fix it?

    • @valzzu
      @valzzu 3 года назад

      same here

    • @deepeddyrecords5933
      @deepeddyrecords5933 3 года назад

      If you're using Linux/UNIX, you may have to open up the permissions of your uploads folder. "chmod 777 uploads" to allow write access.

  • @stepniak18
    @stepniak18 4 года назад +7

    I needed a hero and then I found this video. Thx, you saved me.

  • @techdedicated
    @techdedicated 6 лет назад +1

    I did everything you did exept on a live server and this doesn't work for me it send me to upload.php after I get done uploading

    • @Flo_Motion
      @Flo_Motion 6 лет назад

      Same, loads white page only on upload.php. Tried doing echo breaks, nothing shows up at all. I just want to upload files to my webserver with button click LOL. Hunter did you ever figure it out?

  • @ehrollbiteng3909
    @ehrollbiteng3909 7 лет назад +3

    Daniel thank you for information

  • @triplea7071
    @triplea7071 4 года назад +3

    i dont care if u believe in GOD or not........bro May ALLAH Bless and Reward you man. I wish u all the best and thanks for this. Super grateful.

  • @burakgursel2473
    @burakgursel2473 6 лет назад +2

    Beni aydınlattığın için seni seviyorum kardeşim ;)

  • @ligmadick3401
    @ligmadick3401 4 года назад +6

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

    • @codeo4469
      @codeo4469 4 года назад

      The code actually works for you? Did everything he did in the video and for some reason code is not working, it displays the error->You cannot upload files of this type.

    • @ligmadick3401
      @ligmadick3401 4 года назад

      @@codeo4469 Feel free to share your source code and I will take a look at it. I will help you as far as I can.

    • @codeo4469
      @codeo4469 4 года назад

      It is a copy of what he did, since im learning, i do copy of his code.. and when i submit an image, whatever kind of those placed in the allowed array, it prints out error

    • @valentinobahati9947
      @valentinobahati9947 4 года назад

      nice tutorial, try this too ruclips.net/video/Hf8bJiRBPio/видео.html

  • @karanveerseniarey7223
    @karanveerseniarey7223 7 месяцев назад +2

    This person is really helpful.

  • @wadwdaaafefawfawawfawerog4335
    @wadwdaaafefawfawawfawerog4335 7 лет назад +3

    Is this vulnereble in ANY way?

    • @wadwdaaafefawfawawfawerog4335
      @wadwdaaafefawfawawfawerog4335 7 лет назад

      anyone?

    • @ben_jammin242
      @ben_jammin242 6 лет назад

      i would like to know myself. the only thing i could think of is that the files are now sitting in the uploads folder, visible to anyone who requests the directory, unless you disable directory browsing

    • @amoghdatar2726
      @amoghdatar2726 6 лет назад +1

      Benjamin Brauer make an index.php file and write header();
      Which takes back to front page so nobody can see the files inside the uploads folder

  • @ayushgupta-ib2kl
    @ayushgupta-ib2kl 7 лет назад +6

    sir why my images can't stored in my uploads folder can you solve this problem

    • @bishoy437
      @bishoy437 7 лет назад +1

      Me too I dont know why :(

    • @sunilreddy9297
      @sunilreddy9297 6 лет назад +1

      Hey try this !!
      Go to xampp config , locate php.ini file find for upload_max_filesize variable and increase the size.
      Then your images will move to dest folder.
      This might help you !!

    • @jBeB1
      @jBeB1 6 лет назад

      it didnt work for me i get no error messages either would appreciate some help

    • @jBeB1
      @jBeB1 6 лет назад +1

      nvm i had a / behind the name of my upload folder

    • @florenzandreyhipolito4113
      @florenzandreyhipolito4113 6 лет назад

      ayush gupta

  • @AnshuAditya111293
    @AnshuAditya111293 7 лет назад +1

    will you please explain how to upload multiple files with the same validation (as you did for single input in this video)

  • @jared4670
    @jared4670 7 лет назад +3

    Hey Daniel,
    Just want to say thanks again for all the great tutorials! You really have helped me ALOT in getting off to a good programming start.
    I would just like to share a neat trick with you for the sublime editor. Press CTRL + H on your keyboard. This allows you to search for whatever you need and replace it with something else. Comes in particularly handy when you need to change " to '.
    Another one if you need to change something in your ENTIRE website is CTRL + SHIFT + F. You can then choose a directory and search for a particular string and of course have the ability to replace it as well.
    Peace!

  • @worldaviation4k
    @worldaviation4k 6 лет назад

    Great video, 1 question: I wanted to upload videos to my private section but have the thumbnail and download link into the public side. So then they click download and the file path is in the private section.
    Thanks very much

  • @TV-vu9fg
    @TV-vu9fg 5 лет назад +1

    For anyone who use mac gets the error "permission denied" can try this way, it worked.
    stackoverflow.com/questions/31915957/move-uploaded-file-failed-to-open-stream-permission-denied-mac

  • @nareshramini1796
    @nareshramini1796 5 лет назад +1

    Please explain the function uniqid(" ", true) Confused on why should you supply empty string as first parameter and boolean true as another 2nd parameter parameter...what these parameters gotta do or what are these parameters instructing uniqid() function to do by taking them??
    Btw great tut!

  • @tutorials9441
    @tutorials9441 4 года назад +1

    how about multiple photos (2 or more photos)? Please someone help.

    • @tanzirroxy9161
      @tanzirroxy9161 4 года назад

      Did you find any good solutions? I am looking for it too.

  • @MrCryoJack
    @MrCryoJack 3 года назад +1

    Great video as always, but I just have a question. I am trying the same thing except I want to upload images to a different folder and save the new file path in the DB. The upload function doesn't seem to be working as the destination folder is in a different place. For the record, the destination folder is one folder up from the folder in which my upload function sits.
    '.. /data/images/profile-pics'
    Am I doing something wrong? (ubuntu 16.04)

    • @edison_kyama
      @edison_kyama 2 года назад +1

      I tried changing from '$fileDestination = 'uploads/'.$fileNameNew;' to '$fileDestination = '../'.$fileNameNew;' and it worked. For me, upload.php is in upload folder which is in htdocs folder so, changing that uploaded the file to htdocs folder. If it's just '$fileDestination = './'.$fileNameNew;', it would upload the file into the same folder as upload.php is in.

  • @brentmarquez4157
    @brentmarquez4157 6 лет назад +1

    for those that got an undefined index error for $_FILES - double check all syntax and code 'grammar'. I left out the dash in form-data in the enctype attribute in tags. mine read:

  • @FreedomForKashmir
    @FreedomForKashmir 5 лет назад +1

    Do anybody know any video where we can upload files and videos to database
    Please help

  • @BaadiyaaTube
    @BaadiyaaTube 2 года назад

    10Q so much. Everything goes right. But file size won't done.
    10Q

  • @pianoLee-sx9dx
    @pianoLee-sx9dx 5 лет назад +1

    It is a good tutorial but at 7:01, it is confusing when you said that we could name it $file['name'] but didn't we call the name=file? must we change the name = 'name';?

    • @nareshramini1796
      @nareshramini1796 5 лет назад

      You'll understand that if you see line 3... On line 3 he actually assigned $_FILES['file'] to the variable $file ( $file=$_FILES['file']; )

  • @perianka
    @perianka 4 года назад +1

    3:20 is creating a button of type submit is the same as creating an input type submit?

    • @pawesmigielski8184
      @pawesmigielski8184 4 года назад +1

      yep, you only give button name in value property e.g

  • @ahmedshehryar
    @ahmedshehryar 2 года назад +1

    First time RUclips recommended something I really needed.
    Excellent tutorial BTW.

    • @ahmedshehryar
      @ahmedshehryar 2 года назад

      Thanks Dani, reply needed that tutorial of yours. I've been stuck on learning to upload a file for like three days probably. Thank you.

  • @ryansgnx
    @ryansgnx 4 года назад +1

    I keep getting "undefined index for $fileName, $fileTmpname $fileSize, $fileError, and $fileType

    • @tanzirroxy9161
      @tanzirroxy9161 4 года назад

      Having same problem and also shows, " Fatal error: Uncaught Error: Call to undefined function array( ). " Let me know if you find any solution to this.

  • @xtordngy
    @xtordngy 5 лет назад +2

    Nice One! you really safe a life right now.

  • @tamilanosai80
    @tamilanosai80 2 года назад

    Hi, best videos Dani & pls make video for /// same script but image uploading location to FTP storage /// with FileZila FTP server or iis FTP server setup & finally FTP location image display on browser, thank you

  • @maroinealarabi1473
    @maroinealarabi1473 Год назад

    when i print_r($file) on 7:17 i get this error
    Warning: Undefined array key "file" in C:\xampp\htdocs\cvResume\upload.php on line 7
    can sb tells why

  • @daarhebjeflipper
    @daarhebjeflipper 6 лет назад +1

    move uploaded file gave an error , fixed it by making the destination ../uploads/

  • @Corzhy0
    @Corzhy0 6 лет назад +1

    Could you please show us how to do this with ajax. Also the user can upload jpg and png images. So if the user changes an image and it is another jpg image for example, the png one will still be there. Your vids are great!!!!

  • @wyattgowing9613
    @wyattgowing9613 2 года назад

    Parse error: syntax error, unexpected '}' in C:\Program Files\xampp\htdocs\wyattprograms\upload.php on line 22

  • @johncovv
    @johncovv 5 лет назад

    To display in the explorer only the files supported in php, include in the FILE INPUT ====> accept = ".jpg, .jpeg, .png, .gif"

  • @polyduralmusic8147
    @polyduralmusic8147 4 года назад

    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

  • @FellTheSky
    @FellTheSky 3 года назад

    this works fine, but I need to send an ID along with the file. So my php script knows what to do with the file...
    I've tried added a in the form. But when its received by the script, its empty. Things I've tried to get the ID input when sending the form (same method as the video, but with an extra input hidden ) :
    $data = json_decode(file_get_contents("php://input"));
    echo var_dump($data); //NULL
    echo var_dump($file); //(GETS the file, nothing about the ID)
    echo var_dump($_POST);//Gets ARRAY(2)[ID]=>String(0)='', [submit]=>String(0)='']
    echo var_dump($_POST['submit']);//string(0) ""
    echo var_dump($_POST['id']);//string(0) ""
    Note: The input hidden has the ID in the form. I've checked the html code while running. It just happens that after submitting the form, its empty.

  • @flint_escobar
    @flint_escobar 3 года назад

    Parse error: syntax error, unexpected variable "$fileName" in D:\Xampp\htdocs\upload.php on line 5
    im getting this error pls help

  • @rockroll4107
    @rockroll4107 2 года назад

    What if I upload "img1.jpeg.exe" to this website you created in the video?
    Does the "end()" get the ".exe" because it's the last '.' ?
    Thank you for the video!

  • @patrickmaine7778
    @patrickmaine7778 4 года назад +1

    When I upload my website and go live, uploading to directory does not work anymore. Please help.

    • @miguelmesen1656
      @miguelmesen1656 4 года назад +1

      Did you check that your upload file is in the exact same folder as your index.php

    • @patrickmaine7778
      @patrickmaine7778 4 года назад

      @@miguelmesen1656 thank you for your respond. Upload folder is in the same folder to the php page that executes the code, it was working when im using localhost server, but when i uploaded it as live website, directory doesnt get any files anymore.

    • @patrickmaine7778
      @patrickmaine7778 4 года назад

      @@miguelmesen1656 i checked it and no files were uploaded. Is it possible that files went to other folder?

  • @yamatoanshu
    @yamatoanshu 2 года назад

    Is this applicable for FTP (like for Uploadify) as well? By using username, password, and server name?

  • @soramakizushi
    @soramakizushi 3 года назад

    What if your php script is not in the root folder?
    Like, what if your upload.php file is in a folder in your root folder called scripts? When setting $fileDestination, do you set it equal to "../uploads/".$fileNameNew;" instead?
    Either way, the move_uploaded_file part just isn't working :(

  • @prabhakaryadav7668
    @prabhakaryadav7668 6 лет назад

    Nice Video!!!!!!!!!!!
    Can You Please Make a Video On How To Upload Audio To Website In PHP

  • @manfriedschmidt5953
    @manfriedschmidt5953 3 года назад +1

    Thank you so much! Exactly what I needed! Pure excellence!

  • @prasantamedhi
    @prasantamedhi 3 года назад

    Hi followed your guidelines but my upload button not responding.. i tried to troubleshoot by changing some ini file variable limits
    post file size limit, upload file size, memory file size limits..
    but still no results
    kindly help me with this ..
    I'm using windows 10 system
    php version 7.14.19 win32 bc15 x86

  • @propleyer2867
    @propleyer2867 3 месяца назад

    about extracting the extension of a file, what if it's name is "test.test.png" ? and thank you

  • @ahmedshehryar
    @ahmedshehryar 2 года назад

    The file isn't POSTed in a website I was making so the isset() returned false.
    What could be the common mistakes I could've made.

  • @marineoutsource
    @marineoutsource 4 года назад

    Hi Daniel, the error handling file is not working for files more than say 2MB (as per my setting) and am getting this type of message . . . Warning: POST Content-Length of 10498205 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
    Got this error message how to get rid of it? (tried restating my XAMPP as suggested in the web but it didn't help). The error handling for file type works in some instances, as for example, i did't allow gif and it's give an error messages and even for allowed file that exceeds max size it gives me the error message correctly (i.e. I cannot upload file of this type) // but for say MP4 type and exceeds file limit it goes to, I guess generic error "WARNING" message . . . how to get rid of that ? please help / thanks

  • @mofufox5855
    @mofufox5855 3 года назад

    after i choose a photo and after i push the upload button I get the error: "Notice: Undefined index: file in C:\xampp\htdocs\php\php_day03\challenge\upload.php on line 5" Can someone help me out?

  • @noyahasan5125
    @noyahasan5125 4 года назад +1

    can u please do a "How to upload a html file with pictures?"

  • @Kakan124
    @Kakan124 6 лет назад

    I have this problem that when i click upload i get stuck on "upload.php?file=SweetChild.jpg&submit=" and nothing else happens. I check the uploads file and its empty. Help?

  • @Lyokoheros-KLPXTV
    @Lyokoheros-KLPXTV 4 года назад

    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.