Post Reply  Post Thread 

Upload file query in PHP
Author Message
jignesh
Moderator

Moderators

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
Send the author an email Send the author a private message Find all posts by this author Quote this message in a reply

Advertisements

This is an ad revenue sharing forum
Nameslot
Administrator

Administrators

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
Send the author an email Send the author a private message Visit authors website Find all posts by this author Quote this message in a reply
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
Send the author a private message Visit authors website Find all posts by this author Quote this message in a reply
Nameslot
Administrator

Administrators

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
Send the author an email Send the author a private message Visit authors website Find all posts by this author Quote this message in a reply
marketstrat
Junior Member



Posts: 2
Group: Registered
   
Cash: 0.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.so any new suggestion ............


Medical Market Research Company | Urodynamics Equipment and Disposables
07-20-2007 11:10 PM
Send the author a private message Find all posts by this author Quote this message in a reply
pranavbhat
Member



Posts: 174
Group: Registered
   
Cash: 101.00 Donate
RE: Upload file query in PHP

yea...i got rid of this problem...PHP has an excellent FTP interface which we can use...do upload files!!


Freelance Web Designer and Programmer
Linux and Open source blog
07-21-2007 12:12 AM
Send the author a private message Visit authors website Find all posts by this author Quote this message in a reply
maximum
Super Moderator

Super Moderators

Posts: 35
Group: Super Moderators
   
Cash: 0.00 Donate
RE: Upload file query in PHP

Maybe a bit more to answering the original question:

PHP Code:

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
Send the author a private message Find all posts by this author Quote this message in a reply

Post Reply  Post Thread 


Similar Threads
Thread: Author Replies: Last Post
PHP File Downloads nick 2 05-13-2006 03:58 AM

View a Printable Version | Send this Thread to a Friend | Subscribe to this Thread | Add Thread to Favorites
Rate This Thread:
Forum Jump: