![]() |
| Upload PHP file code |
|
gilbertsavier
|
Hi,
I need a code that lets my customers upload a image file from their computer and then that file does 2 things 1. gets uploaded to upload folder on my server 2. a copy of that file gets e-mailed to me this is what I have so far, any improvements/additions on this code would really be appreciated... 1.//GET IMAGE INFO 2. 3. $dir = 'images/'; 4. $file_name = $_FILES['file']['name']; 5. $file_tmp = $_FILES['file']['tmp_name']; 6. 7. //CHECK FOR UPLOADED FILE 8. if(is_uploaded_file($file_tmp)){ 9. //MOVE TO DIR 10. move_uploaded_file($file_tmp, $dir.$file_name); 11. } |
||||||||||||
|
|
|||||||||||||
|
nathacof
Forum Admin
|
http://us2.php.net/manual/en/features.file-upload.php is a great reference for this.
Look out for these, http://us2.php.net/manual/en/features.file-upload.common-pitfalls.php Here's a good function to display the appropriate error message in the event a file upload fails: http://us2.php.net/manual/en/features.file-upload.errors.php#90522 Depending on the size of uploaded files you might just want to email yourself a link to the file. |
||||||||||||
|
|
|||||||||||||
| Please help "Upload file with PHP" |
|
ravirake
|
No matter how I change the code the file doesn't upload to the server and I have gone the above links and tried but nothing works. Please help. |
||||||||||||||
|
|
|||||||||||||||
|
jamie
HostMySite Sales Rep
![]()
|
If you're hosting with us send that into support@hostmysite.com and let them know what your account is. While code support is technically not their province a simple upload script should be easy - may just be a matter of file permissions on the server, pathing, etc.
|
||||||||||||
|
|
|||||||||||||
|
nathacof
Forum Admin
|
Your $uploaddir variable needs to be set to the actual path to the directory on the server. On our shared Linux plans, the absolute path to your site's document root is:
Replace <ftpusername> with the primary FTP username for your account. |
||||||||||||||
|
|
|||||||||||||||
| Upload PHP file code |
|
||
|



