Php image upload help required

Status
Not open for further replies.

reverbstudios

New Member
I'm new enough to php coding and I'm trying to build a basic php driven template site from which I can take code snippets for other projects/sites. This template site will have all of the most basic dynamic functions including:
  • Membership
  • Login
  • Profile Update
  • Add, Delete, Update Product
  • Show items from database
  • etc..
I've managed most of this already but 1 small thing has got the better of me - image upload.

I wish to include an image upload field in both my existing signup and profile update forms which grabs an image off the pc and stores it in the database then shows it in the profile.

Anybody any ideas or code snippets - I specifically need a form with image upload included and not just an image upload script as I wouldn't know how to add that to my form?
 

louie

New Member
It's very simple.
A very important thing you need to do is setting the form as "enctype="multipart/form-data"
Code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">

other fields here
... then the upload form field
 
Upload Image: <input type="file" name="imgfile">
</form>

if you Google you get lots of samples:

php image upload - Google Search
 

reverbstudios

New Member
I've seen that example before many times and done lots of googles but what I really need to know is the bit where you tell the image where to go (folder) and how to add it to the database etc..my form file is attached so you know what I mean.
 

reverbstudios

New Member
Thanks, thats kinda double dutch to me though..I can't write php code from scratch yet, most of the code in that file attached was borrowed from other applications!

If you have a working form code doing the same thing as I'm trying that would be perfect. Then I could substitute the variables to my own etc..
 

louie

New Member
My code is broken apart in several function-pages and I am afraid if I'll give it to you, you wouldn't know what to do with it. Why don't you try to do something yourself, than look for help here to get the code right.
 

reverbstudios

New Member
Well I'm good at figuring out existing code. Wouldn't have a clue where to start with writing it though. Anyway, the code I attached is my effort so far so if anyone knows how to get an image upload into that I'd be grateful. Its too long to post the code naked here
 

reverbstudios

New Member
I think I have followed something like that but got errors and hadn't a clue where to go! I'll give that one a bash thanx..
 

littleBird

New Member
I hope reverbstudios has sorted out their upload problems but I am having some of my own at the moment.

I am very familiar with PHP coding and have created many different upload functions before. one I am currently working on is embedded within a Wordpress website. For some reason, code that I have successfully used on other none-wordpress sites refuses to work now. It keeps giving me the error on move_upload_file of "failed to open stream: HTTP wrapper does not support writeable connections."

Has anybody experienced this before and can you shed some light on how I can resolve this?
 
Status
Not open for further replies.
Top