FInally somebody explained us how to do this! Thank you very much for this! For those people who's project is not working properly, please make sure you setted the next permission on the "uploads/" folder on linux. (chmod 0777 uploads/) It allowes your site to create files into the folder.
Here's a little thing that tripped me up: when you're testing it out, make sure you are loading your pages from the server, and not from your computer's file directory. If you are opening the files locally, when you click the 'upload' button, it is going to open the php file, and just show you the code you wrote. If you are using Windows, you'll want the url to start with localhost, not C/Program%20Files or something similar.
Is it possible to upload a file via a string that was given to the script per POST-Method? So like the post-info "file" is "C:/.../file.txt" and then the file file.txt gets uploaded. So that I don't have to use a file browser but just copy the directory as a string in a form for example?
I have used this video to make an upload project but for mp3's however that seems really unstable, even after I have added quite a few different mp3-types to the array. Any suggestions? For now I work in localhost
Dear Sir, thank you for sharing.May I know where the uploaded files will be saved?If there are many files from the public, the space may be full on our PC.
Awesome. I'm trying to learn about loading images to a MySQL database into as a BLOB and then recalling it to a page from the Database. Do you have a video about that? If so, I have not found it yet.
Too many unneeded variables. once you copy $_FILES['file'] to $file Using the $file array is enough you dont need to assign more variables... This would be a good time to make a video about references/pointers
Thanks for the comment, it just made things clearer and if they're required again they would be useful - but you're right, in this example they're not absolutely required.
I think its not vulnerable for double extension because he is splitting the filename into a array. He is using as split the "." and he will get a array. If u take "name.php.txt" you will get a array with "name|php|txt". He is taking the last element of the array for the extension wich will be correct in this case. I cant think about a case where this wont work.
Oh no no no noo. The tutorial is pretty good, but checking the ext can pretty much f the whole system up. I recommend checking the MIME type instead (and google to find more security uploadings with php as well). If not then anyone can change uploading file types i.e. myPdf.pdf to myPdf.jpg and wolaaa, it gets uploaded. Also I recommend using the uniqid(mt_rand(), true). Otherwise a good and helpful tutorial.
Just print out the location of the file inside an HTML img tag, you still need to wait for the file to be uploaded in order to do this, or you can also use AJAX for make it look better. You can archieve this in the client using any HTML5 feature too but that could a bit more advanced.
+John Reeves I'm replying to myself here, but the issue ended up being that the maximum upload size was limited to 2MB by my php.ini file. I raised it, and then my mp3s went through to the uploads folder. Make sure you restart apache/your server so that the changes to php.ini take effect.
Hi Sir Alex, could you please do sample tutorial in php, like login authentication if the user fail to login 3 times the users were going to ban.thank you .
This is fairly easy to do, I'm assuming you know how to use the PHP insert and mysql_query feature. How I do this is I make a database table called "login attempts" to store every login attempt. You can do PHP to select data from there and compare them using mysql_num_rows and see if there are 3 for a specific user. Sorry if this was confusing.
that might be because you do not have read & write permission for that folder. Assuming you are testing all this out in your local machine using XAMPP or WAMPP, (on windows) you can select the folder you are trying to move the file to, right click it, go to the Security tab and enable permissions for all users. (on Mac) right click on the desired folder, Get info, select everyone at the bottom, double click on "everyone" and select "Read & Write". I reckon on a domain all the privileges are set by default to read and write but I might be wrong. Hope this helped :) cheers
Nice voice and accent! Not a tutorial for beginners. Way too much mumbo jumbo for people who want to learn a basic file upload in php. Overall, bad! The essence of teaching something is starting from the premise that the people who are learning from you have no idea what they're doing. It takes a skilled educator to move slowly through and explain in a deliberate manner as if talking to a child because that's where learners are at, they are at a childlike state. What would have been constructive is to start from basic file upload and then in subsequent tutorials to add things like file ext and size checking.
I think it is the easiest way he can tell us as spectators how a file transfer script is working. Iam a beginner in php too and i could understand it easily.