473,704 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Uploading Photos Help

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
6 4468
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($FileToUp load, "./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($FileToU pload);
}
?>
HTML code:
<form method="post" action="file.ph p">
<input type="File" name="FileToUpl oad">
<input type="submit" value="submit">
<input type="reset" value="reset">
</form>

On Sat, 23 Aug 2003 14:44:20 GMT, Ralph Freshour <ra***@primemai l.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
On Sun, 24 Aug 2003 03:02:52 GMT
Ralph Freshour <ra***@primemai l.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
On Sun, 24 Aug 2003 21:12:58 +1000
Matthew Vickers <ke**@replies.i n.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
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***@primemai l.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
On Sun, 24 Aug 2003 21:38:11 GMT
Ralph Freshour <ra***@primemai l.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
$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.i n.ng> wrote:
On Sun, 24 Aug 2003 21:38:11 GMT
Ralph Freshour <ra***@primemai l.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2280
by: Jeff Alu | last post by:
Hi, I'm moving a website to a new location for a friend of mine. The old site http://www.infomercialavails.com Is working fine. However, the php files at the new location seem to be having problems: http://www.steve5252.addr.com/
2
2216
by: Ross | last post by:
Hi I have an application using asp.net that I am running on my PC. The web form has a text box where you can enter a name for a new Photo category then click on the button. The code is intended to create a new directory under Photos such as "Relatives".
2
1411
by: laredotornado | last post by:
Hi, I'm using PHP 4 and trying to upload an image. I think I'm using the right "enctype". Here is the form I submit <form name=addPhotoForm enctype="multipart/form-data" method=post action="add_photo_response.php"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr><td colspan="2" align="center" class="subHeaderClass">Add Photo</td></tr>
4
29846
by: Mukesh | last post by:
Hi all I am trying to upload and save as a picture to "root/Photos" folder in my web application. I am using this code to perform this task DirectoryInfo strFolder = new DirectoryInfo("/Photos/"); if (!strFolder.Exists) { strFolder.Create(); }
4
3604
by: cheryl | last post by:
We are asked to create a website that can upload photos....Our website administrator must upload photos. His upoloaded photos must reflect on the users interface.. I dont know where and how to start with this module. can you help me to find codes in uploading photos?
2
1328
by: mike_ni | last post by:
im designing a site (still in my head at the moment) where users will be able to upload photos but I would like somewhere in the upload process, for these photos to be resized down to e.g 600 x 400 to reduce the database size, keep the output a standardised on screen and to reduce viewing/downloading times. Has anyone any ideas, examples or pointers to help me out on this one, as I am still learning. thanks mike
1
1883
by: recordlovelife | last post by:
Hi all. I need to make a file uploader, so a client can upload pictures to a directory on their shared server, so that they can later include the photos in news updates. I simply want to take this form: <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br />
1
1428
by: Mufasa | last post by:
Is there any way with the fileupload control to not have it upload the file if it's to big? I want to set a 5MB limit but don't want to have the user upload a 50MB only to be told once it's done that the file is to big. TIA - Jeff.
1
2587
by: davidson1 | last post by:
Hello friends, I have to load Photos in internet so that it should be seen by friends by using URL.Do u know any website ,so that we can load photos(many photos) collectively.Suppose for example tour photo = 24 College Photo = 24 Home Photo =22 3 division,inside each photos must be loaded
0
8766
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8684
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9025
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8975
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4438
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4699
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2478
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2078
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.