• Welcome to NamesLot.com Domain Name Forum

    NamesLot.com Domain Name Forum offers a fully open forum to discuss domain industry news and a 0% commission marketplace for you to buy and sell domain names.

    We have reorganized our Marketplace so now it is easier to get attention to your domain while it is also easier for buyers to find the right domain name.

    If you want us to add more threads to our marketplace, please contact us! Listing on our marketplace as always, 100% free! Register NOW or Login HERE!

Upload file query in PHP

Status
Not open for further replies.

jignesh

New Member
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
 
$_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.
 
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
 
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.
 
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 ............
 
Maybe a bit more to answering the original question:

PHP:
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
 
Status
Not open for further replies.

Members online

No members online now.

Forum statistics

Threads
19,801
Messages
69,798
Members
44,585
Latest member
tsscgroup
Active members today
0
New members today
0
New threads today
2
New posts today
2

Follow NamesLot on Twitter!

NamesLot proudly supported by

NamesLot proudly supported by

Top