Upload Files!
am 15.04.2008 15:50:52 von Matthew Gonzales
Hello,
I am wondering if anyone out might be able to point me in the right
direction on uploading files from a website into MySQL Databses. I am
trying to create a way for members to upload files and associate them
with there user profile. What data type must I use. Thanks for your help
in advance.
Matt G
--
Matthew Gonzales
IT Professional Specialist
Enterprise Information Technology Services
University of Georgia
Email: matt323@uga.edu
Phone: (706)542-9538
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Upload Files!
am 15.04.2008 16:42:43 von Jarrett Meyer
Files and all associated properties are saved in the $_FILES[] variable. From
here, you can get the file name, file size, etc.
I would recommend that you come up with your own name for the file. My code may
not be right, but it will be close.
$LocalFilePath = /path/to/local/files/
$LocalFileName = md5($_FILES[]["name"]);
// perform an action to save the file locally.
Assuming that you have the user name from the session data,
$Sql = "insert into UserFiles
(User, Filename, Extension, Date)
values
($_SESSION["user"]
,$LocalFileName
,$_FILE[]["type"]
,time())";
Now you've got a database of all files saved by user.
See http://us3.php.net/features.file-upload for more info about the $_FILES
variable.
Jarrett M
Matthew Gonzales wrote:
> Hello,
>
> I am wondering if anyone out might be able to point me in the right
> direction on uploading files from a website into MySQL Databses. I am
> trying to create a way for members to upload files and associate them
> with there user profile. What data type must I use. Thanks for your help
> in advance.
>
> Matt G
>
--
Jarrett M. T. Meyer, M.B.A.
jmtmeyer@yahoo.com
http://www.jarrettmeyer.com
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Upload Files!
am 18.04.2008 06:50:46 von joconnor
"Jarrett Meyer" wrote in message
news:4804BEE3.9010105@yahoo.com...
> Files and all associated properties are saved in the $_FILES[] variable.
> From here, you can get the file name, file size, etc.
>
> I would recommend that you come up with your own name for the file. My
> code may not be right, but it will be close.
>
> $LocalFilePath = /path/to/local/files/
> $LocalFileName = md5($_FILES[]["name"]);
>
> // perform an action to save the file locally.
>
> Assuming that you have the user name from the session data,
>
> $Sql = "insert into UserFiles
> (User, Filename, Extension, Date)
> values
> ($_SESSION["user"]
> ,$LocalFileName
> ,$_FILE[]["type"]
> ,time())";
>
> Now you've got a database of all files saved by user.
>
> See http://us3.php.net/features.file-upload for more info about the
> $_FILES variable.
>
> Jarrett M
>
> Matthew Gonzales wrote:
>> Hello,
>>
>> I am wondering if anyone out might be able to point me in the right
>> direction on uploading files from a website into MySQL Databses. I am
>> trying to create a way for members to upload files and associate them
>> with there user profile. What data type must I use. Thanks for your help
>> in advance.
Also the datatype can be BLOB, MEDIUMBLOB or LONGBLOB.
Jeremy O'Connor
--
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Upload Files!
am 18.04.2008 11:21:49 von Michael Southworth
------=_Part_1300_22675852.1208510509394
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
At first blush, this article may be the best place to start. It has a
complete example from start to finish. In addition to what has been stated
here, you will need to properly SQL escape the data before inserting and
un-escape it after fetching it from the database.
http://www.onlamp.com/pub/a/php/2000/09/15/php_mysql.html
I'm no expert on SQL, but from what I have gathered from my experience,
storing large binary files in a database has generally been a good way to
slow down a database quickly, mostly because the entries become quite large,
and causes the database size overall to get very large.
Take a look at :
http://aspnet.4guysfromrolla.com/articles/120606-1.aspx
or
http://www.onlamp.com/pub/a/onlamp/2002/07/11/MySQLtips.html
#4
before you make any decisions on what path to go down. These were the first
articles I could find on Google, there are probably better.
HTH,
-Mike
On Thu, Apr 17, 2008 at 9:50 PM, Jeremy O'Connor
wrote:
> "Jarrett Meyer" wrote in message
> news:4804BEE3.9010105@yahoo.com...
> > Files and all associated properties are saved in the $_FILES[] variable.
> > From here, you can get the file name, file size, etc.
> >
> > I would recommend that you come up with your own name for the file. My
> > code may not be right, but it will be close.
> >
> > $LocalFilePath = /path/to/local/files/
> > $LocalFileName = md5($_FILES[]["name"]);
> >
> > // perform an action to save the file locally.
> >
> > Assuming that you have the user name from the session data,
> >
> > $Sql = "insert into UserFiles
> > (User, Filename, Extension, Date)
> > values
> > ($_SESSION["user"]
> > ,$LocalFileName
> > ,$_FILE[]["type"]
> > ,time())";
> >
> > Now you've got a database of all files saved by user.
> >
> > See http://us3.php.net/features.file-upload for more info about the
> > $_FILES variable.
> >
> > Jarrett M
> >
> > Matthew Gonzales wrote:
> >> Hello,
> >>
> >> I am wondering if anyone out might be able to point me in the right
> >> direction on uploading files from a website into MySQL Databses. I am
> >> trying to create a way for members to upload files and associate them
> >> with there user profile. What data type must I use. Thanks for your
> help
> >> in advance.
>
> Also the datatype can be BLOB, MEDIUMBLOB or LONGBLOB.
>
> Jeremy O'Connor
> --
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
------=_Part_1300_22675852.1208510509394--