By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,852 Members | 994 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,852 IT Pros & Developers. It's quick & easy.

Uploading Photos Help

P: n/a
I'm trying to code the ability for my users to upload up to photo's to
mysql database - can someone point me in the right direction as to how
this might be done in php? Perhaps a tutorial or some code samples?
My two php books don't cover uploading photo's to a web site.

Thanks...

Jul 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
OK, I'm uisng the code below (file.php and file.html) and I'm getting
the following error:

Parse error: parse error, expecting `','' or `';'' in
/home/user/public_html/file.php on line 15

line 15 is the echo 'File Name line below - I don't understand what
the error is and I also don't understand how the if ($File_name) var
is working - where is this var coming from???

file.php code:
<?php
if ($File_name)
{
if (copy($FileToUpload, "./uploads/$File_name"))
{
echo 'File Name :' . $File_name .';
echo 'File Size :' . $File_size .';
echo 'The file was successfully uploaded!';
}
else
{
echo 'Your file could not be copied.';
}
unlink($FileToUpload);
}
?>
HTML code:
<form method="post" action="file.php">
<input type="File" name="FileToUpload">
<input type="submit" value="submit">
<input type="reset" value="reset">
</form>

On Sat, 23 Aug 2003 14:44:20 GMT, Ralph Freshour <ra***@primemail.com>
wrote:
I'm trying to code the ability for my users to upload up to photo's to
mysql database - can someone point me in the right direction as to how
this might be done in php? Perhaps a tutorial or some code samples?
My two php books don't cover uploading photo's to a web site.

Thanks...


Jul 16 '05 #2

P: n/a
On Sun, 24 Aug 2003 03:02:52 GMT
Ralph Freshour <ra***@primemail.com> wrote:

<snip>
Parse error: parse error, expecting `','' or `';'' in
/home/user/public_html/file.php on line 15
The PHP engine can not parse your php file on line 15. It looks like it cannot tell where your statement ends because you have not closed the final string concatenation.
echo 'File Name :' . $File_name .';
try: echo "File Name : $File_name";

<snip> I also don't understand how the if ($File_name) var
is working - where is this var coming from???


You don't know ? Did you declare it ? From the code supplied the if statement will never be executed because $File_name doesn't exist.

Clear as mud ?

Matt

--
Quispiam Power Computing | "There are two major products that come out
Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
+61 2 9688 2894 | this to be a coincidence. "
www.quispiam.com | - Jeremy S. Anderson
Jul 16 '05 #3

P: n/a
On Sun, 24 Aug 2003 21:12:58 +1000
Matthew Vickers <ke**@replies.in.ng> wrote:

<Snip unwrapped junk>

Sorry 'bout that. Line wrapping was not set correctly.
Matt

--
Quispiam Power Computing | "There are two major products that come out
Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
+61 2 9688 2894 | this to be a coincidence. "
www.quispiam.com | - Jeremy S. Anderson
Jul 16 '05 #4

P: n/a
Thanks for the help with the image uploading - the last part I'm
having trouble with is getting the image into a MySQL table col - I
have the col defined as a textblob but after executing the following
code, all I see in the table col is the filename, not the image - but
I'm wondering now if maybe I *should* be only storing the filename in
the table and leave the image on the server????

$php_SQL = "UPDATE photos SET photo1 = '".$php_file."'"." WHERE
member_name = '".$php_member_name."'";

Ralph

On Sat, 23 Aug 2003 14:44:20 GMT, Ralph Freshour <ra***@primemail.com>
wrote:
I'm trying to code the ability for my users to upload up to photo's to
mysql database - can someone point me in the right direction as to how
this might be done in php? Perhaps a tutorial or some code samples?
My two php books don't cover uploading photo's to a web site.

Thanks...


Jul 16 '05 #5

P: n/a
On Sun, 24 Aug 2003 21:38:11 GMT
Ralph Freshour <ra***@primemail.com> wrote:
Thanks for the help with the image uploading - the last part I'm
having trouble with is getting the image into a MySQL table col - I
have the col defined as a textblob but after executing the following
code, all I see in the table col is the filename, not the image - but
I'm wondering now if maybe I *should* be only storing the filename in
the table and leave the image on the server????
Does the variable $php_file contain the image or the image name ?
The column type of textblob doesn't make any sense to me. Do you mean a
blob or a text column ? The column type is academic anyway as
either a text or blob column will do for an image AFAIK.
I'm wondering now if maybe I *should* be only storing the filename in
the table and leave the image on the server????


This is the way I usually do it, it can be done by storing the image in
the DB but IMHO its really not worth the extra work.
Matt

--
Quispiam Power Computing | "There are two major products that come out
Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
+61 2 9688 2894 | this to be a coincidence. "
www.quispiam.com | - Jeremy S. Anderson
Jul 16 '05 #6

P: n/a
$php_file contains the filename so I guess thats why its just writing
the filename to the table - how do I get a var to actually hold the
image so I can write that to the table?

I initially choose the wrong col type - I've now changed it to
mediumblob from textblob which, as you indicated, didn't make any
sense for an image type.

I'd like to store the actual image in the table vs leaving it on the
server.
On Mon, 25 Aug 2003 07:58:52 +1000, Matthew Vickers
<ke**@replies.in.ng> wrote:
On Sun, 24 Aug 2003 21:38:11 GMT
Ralph Freshour <ra***@primemail.com> wrote:
Thanks for the help with the image uploading - the last part I'm
having trouble with is getting the image into a MySQL table col - I
have the col defined as a textblob but after executing the following
code, all I see in the table col is the filename, not the image - but
I'm wondering now if maybe I *should* be only storing the filename in
the table and leave the image on the server????


Does the variable $php_file contain the image or the image name ?
The column type of textblob doesn't make any sense to me. Do you mean a
blob or a text column ? The column type is academic anyway as
either a text or blob column will do for an image AFAIK.
I'm wondering now if maybe I *should* be only storing the filename in
the table and leave the image on the server????


This is the way I usually do it, it can be done by storing the image in
the DB but IMHO its really not worth the extra work.
Matt


Jul 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.