Page 1 of 1

[SOLVED] Upload file

Posted: Tue Mar 27, 2007 2:55 am
by S_henry
Hi guys.. In my PHP web-based system, I want to do one part that can upload file into the folder. For example, in this system, there are one page to register user. In this page I can enter all user profiles. Then I can upload user's photo and I want to save/upload this photo into one folder called 'photo'. I run this system on my server using Centos as my Operating System. The problem now is I don't know the code to upload file into the folder. Anybody can help me please?

Posted: Tue Mar 27, 2007 3:25 am
by impulse()
Use a HTML upload form and then you'll need to look into http://uk.php.net/manual/en/function.mo ... d-file.php

Posted: Tue Mar 27, 2007 8:51 am
by feyd
Also, be aware that the "type" information sent to php is entirely user controlled and therefore completely unreliable. You must do your own checks to ensure the file is a type you are wanting to accept.

Posted: Thu Mar 29, 2007 3:07 am
by S_henry
Now I can upload file into the folder. But its only work on Windows. When I put the system into the Centos server, it won't work. I can use two functions for this and both work on Windows. These are the funtions:

Code: Select all

move_uploaded_file($filename,$uploadpath."/".$filename_name);
//or
copy($filename,$uploadpath."/".$filename_name);
Anybody have any idea on this please?

Posted: Thu Mar 29, 2007 3:24 am
by s.dot
you must chmod() the destination folder to give it the correct permissions

Posted: Fri Mar 30, 2007 2:17 am
by S_henry
OK. Now solved. Thanks guys. :D