Please help PHP......Browse picture and save into Mysql

images php coding issues or problems here.

Moderators: macek, egami, gesf

sun373
New php-forum User
New php-forum User
Posts: 11
Joined: Fri Nov 04, 2005 6:13 pm

Please help PHP......Browse picture and save into Mysql

Postby sun373 » Fri Nov 04, 2005 6:19 pm

Anyone can help...please . I am trying to save piture into Mysql but I don't know how to do. It should check the file size and also check the extension such as gif , jpg.............. anyone know.how to do it..HELP

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Fri Nov 04, 2005 6:57 pm

Welcome to php-forum.com sun373!
Check out this post!

sun373
New php-forum User
New php-forum User
Posts: 11
Joined: Fri Nov 04, 2005 6:13 pm

Postby sun373 » Fri Nov 04, 2005 9:55 pm

Thanks you so much Gesf but what I mean is that I tried to save the name of image into Mysql but the actual image saves in folder name MyImage. I really don't know how to do it !!!! :(

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Sat Nov 05, 2005 3:54 am

Can you show us your code ? It whould be easier!

sun373
New php-forum User
New php-forum User
Posts: 11
Joined: Fri Nov 04, 2005 6:13 pm

Postby sun373 » Sat Nov 05, 2005 4:08 am

I got this error
Warning: filesize() [function.filesize]: stat failed for we.jpg in c:\rat\Project\pr.php on line 12
insert into images (Image) values('we.jpg')
insert OK
Warning: copy(we.jpg) [function.copy]: failed to open stream: No such file or directory in c:\rat\Project\pr.php on line 22

sun373
New php-forum User
New php-forum User
Posts: 11
Joined: Fri Nov 04, 2005 6:13 pm

Postby sun373 » Sat Nov 05, 2005 4:10 am

This code that I tried
<FORM METHOD=POST ACTION="newsticker.php" >
Picture::<INPUT TYPE="file" NAME="picture"><br>
<INPUT TYPE="submit" value="Post"><INPUT TYPE="reset">
</FORM>

sun373
New php-forum User
New php-forum User
Posts: 11
Joined: Fri Nov 04, 2005 6:13 pm

Postby sun373 » Sat Nov 05, 2005 4:15 am

I tried to post the rest of the code but I don't know why it did not allow me to do it !!

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Sat Nov 05, 2005 4:44 am

As i see from your code, you're likely "sending" (copy()) the uploaded file to a folder. You don't need that.
Also you need a form like:

Code: Select all

<form method="post" enctype="multipart/form-data">
     Image file: <input type="file" name="userfile" size="40">
     <input type="submit" value="submit">
</form>
See the enctype="multipart/form-data" and type="file" ? Try the code i showed you.
After uploading the file, the information about the files' size, which you'll store in you MySQL table will be in $_FILES['userfile']['size'];


Return to “PHP coding => Images”

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

cron