PDA

View Full Version : Uploading files in PHP


llbbl
04-22-2005, 12:21 PM
If you want to store the name of the file that you have just uploaded in a database than its a good idea to use urlencode($file); before the form is submitted and before the query is formed to be INSERT'd to use the correlating function urldecode($file).

http://us2.php.net/manual/en/function.urlencode.php


Here is some code to move the file to a directory.


move_uploaded_file($_FILE['event']['tmp_name'], '/path/to/file.txt');


The function basename() might help in determining direcotry path of the file is stored.

http://us4.php.net/basename

llbbl
04-22-2005, 01:03 PM
Also uploading large files (greater than 2 MB) you will have to change a setting in the php.ini file to enable this to happen.

llbbl
04-22-2005, 01:30 PM
Here is some free code that can provide the basis of your upload script. It is good way to learn how to do it.

http://www.maaking.com/index.php?loadpage=scripts

dang
04-22-2005, 01:33 PM
you can actually change the upload max size from within php if you dont have access to the php.ini and you dont want to make it global.

Also, if you have open_base_dir turned on you will need to make sure your tmp folder is set to be allowed access

llbbl
04-25-2005, 05:45 AM
how do u change max size dang/?

what tmp folder? are you talking about checking permissions on the directory where you are uploading files to ?

gary_hendricks
04-25-2005, 06:05 AM
If you guys don't mind my asking, is there a good website on PHP you can recommend? I've been trying to pick it up but am not sure which resource is better.

llbbl
04-26-2005, 10:19 AM
Get a book if you are interested in learning. Do you know C++ or any other programming language already?

Tychovk
04-27-2005, 10:04 PM
What books do you recommend? there are a lot, I'm looking for a good one as well...

a lot, very expensive....

llbbl
04-28-2005, 07:57 AM
Here are two that I own, and think are really good.

http://www.amazon.com/exec/obidos/tg/detail/-/1893115518/

http://www.amazon.com/exec/obidos/tg/detail/-/1565926811/

Theses also might work for you.

http://www.amazon.com/exec/obidos/tg/detail/-/0764579665/

http://www.amazon.com/exec/obidos/tg/detail/-/0764557831/

http://www.amazon.com/exec/obidos/tg/detail/-/0596005431/

Tychovk
04-29-2005, 09:13 AM
thanks :rolleyes: :cool: :) :thumb

llbbl
04-29-2005, 10:02 AM
No Problem ...
Websites:
http://www.phpbuilder.com/
http://groups-beta.google.com/group/comp.lang.php?hl=en
http://groups-beta.google.com/group/alt.comp.lang.php?hl=en
http://groups-beta.google.com/group/Apache-PHP-mysql?hl=en
http://www.devshed.com/c/b/PHP

Intro Tutorials:
http://us2.php.net/manual/en/tutorial.php
http://www.w3schools.com/php/default.asp
http://www.freewebmasterhelp.com/tutorials/php

Advanced Tutorials:
http://www.zend.com/zend/tut/