| Upload file query in PHP |
| Author |
Message |
jignesh
Moderator
    
Posts: 366
Group: Moderators
  Cash: 307.00 Donate
|
|
Upload file query in PHP
hello,
to upload any file in php we need to use input type as 'file' but i have one doubt while we get data in $_FILES array using following syntax,
$_FILES['userfile']['name']
$_FILES['userfile']['tmp_name']
my doubt is what is the diff bet name and tmp_name ?? or we can use both to access file or read file or any file related action??
thakns
Technical Information | Technical World | Seo Services india | BizComSoft
|
|
| 05-22-2007 04:58 PM |
|
 |
Advertisements
|
This is an ad revenue sharing forum
|
| |
|
 |
Nameslot
Administrator
      
Posts: 1,538
Group: Administrators
      Cash: 500.50 Donate
|
|
RE: Upload file query in PHP
$_FILES['userfile']['name'] = The original name of the file on the client machine.
$_FILES['userfile']['tmp_name'] =
The temporary filename of the file in which the uploaded file was stored on the server.
What happens is that the tmp_name is the file stored in the upload folder temporarily. In the upload process there should be yet another line which will copy or move the file from the temp directory to your upload directory.
So to make changes or play with the uploaded file in your script you can do the operations with the tmp_name and then move the file in the proper place.
I usually use a function for this purposes which I created sometime ago. So everytime I need some file upload functions in my script I don't get confused.
Nameslot.com | Do you have a question? shoot me a PM.
|
|
| 05-24-2007 01:12 AM |
|
 |
pranavbhat
Member
  
Posts: 174
Group: Registered
 Cash: 101.00 Donate
|
|
RE: Upload file query in PHP
this thing works fine if the file is small...
but i am also facing this problem for a long time, what if the file is big...then the connection eventually times out and file upload aborts!
nameslot please us what if the file is large say above 100MB
Freelance Web Designer and Programmer
Linux and Open source blog
|
|
| 05-24-2007 02:04 AM |
|
 |
Nameslot
Administrator
      
Posts: 1,538
Group: Administrators
      Cash: 500.50 Donate
|
|
RE: Upload file query in PHP
Well I have never used my function for a file larger then 100 KB's as they are mostly images and other smaller zip files.
But to be on safer side I also did thought of the time out and max file size problems.
It depends on your server side configuration to check the max file size allowed you can do a php info check.
You can also set the max file size allowed on some shared servers. If you have a dedicated server then there's no issue.
Nameslot.com | Do you have a question? shoot me a PM.
|
|
| 05-24-2007 02:21 AM |
|
 |
marketstrat
Junior Member
 
Posts: 2
Group: Registered
 Cash: 0.00 Donate
|
|
| 07-20-2007 11:10 PM |
|
 |
pranavbhat
Member
  
Posts: 174
Group: Registered
 Cash: 101.00 Donate
|
|
| 07-21-2007 12:12 AM |
|
 |
maximum
Super Moderator
     
Posts: 35
Group: Super Moderators
 Cash: 0.00 Donate
|
|
RE: Upload file query in PHP
Maybe a bit more to answering the original question:
move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], "../uploads/{$_FILES['uploadFile'] ['name']}");
This would move the tmp_name file to a location inside your "../uploads/" directory, where you can then access it.
If you have access to the server's php.ini file, you can solve the size problem by adjusting the following settings (may want to read-up on them:wink: ). You can search for methods of changing PHP directives via .htaccess, if you don't have root access, but usually this will not work to alter these settings:
upload_max_filesize
max_input_time
memory_limit
max_execution_time
post_max_size
Domains for sale: www.MyDomains.net/ForSale
The domain MyDomains.net is also for sale over at Sedo.com!
This post was last modified: 07-25-2007 03:44 AM by maximum.
|
|
| 07-25-2007 03:42 AM |
|
 |