file upload help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
barnes529
Forum Newbie
Posts: 17
Joined: Thu Apr 19, 2007 4:18 am

file upload help

Post by barnes529 »

while registering new user.he is uploading his photo.how to store these files in database.if we running script on server.the path of the uploaded file(server) is stored in databse.but now i am running on localhost.how to store uploaded in database.
i need clear explanation about file uploading on server and localhost..thanks in advance for any help..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

There's rarely much of a difference between localhost and server unless you are using completely different server software.

The recommendation is to never store files in the database unless you absolutely, at a last resort, have to.
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

Storing the file in database is a bad Idea.Just store teh file location in the database.
If you are thinking about the security Just put this .htaccess file in that dir where your uploaded files stays.

Code: Select all

Deny from all
<FilesMatch "^.*\.php|.*\.html$">
  ForceType application/x-httpd-php-source
</FilesMatch>
barnes529
Forum Newbie
Posts: 17
Joined: Thu Apr 19, 2007 4:18 am

Post by barnes529 »

okay..how to store path uploaded file in the databse.i am working on localhost.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Look for previous threads on the subject.

Also, look at what is in $_FILES.
barnes529
Forum Newbie
Posts: 17
Joined: Thu Apr 19, 2007 4:18 am

Post by barnes529 »

i am working on localhost.after uploading a file the file is stored in temp folder (www folder).i can store it in sepearte folder also.but how to store uploaded file path in database.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Do you understand how to store a string in the database? Same concept.
Post Reply