Jump to content

Adding picture upload to existing form.


fredted40x

Recommended Posts

Hi,

 

I have a basic form that lets people enter details

 

<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Second name: <input type="text" name="sname" />
<input type="submit" />
</form>

 

And the standard insert in sql command.

 

Im now looking to add a image uplad field the the same form. I have tried several methods off the internet but i cant get any to work. I would like the form to upload the image into the directory '../images' and then save the path to the file in the database, e.g. 'images/picture.jpg'.

 

Can anyone point me in the right direction please. Im guessing i will have to use the file input type but i cant get any of it to work.

 

Thanks

Link to comment
Share on other sites

Thanks for your reply. It looks similar to one i've tried before.

 

I found that when i add the code

enctype="multipart/form-data"

 

It no longer submits to the database. Would that be because it also has text inputs in the form as well?

 

Your welcome =)

 

Probably not. You're going to have to show me the php and html code before I can help. It's most likely an issue with your php code, or perhaps you misspelled something? 9 times out of 10 its a small typo, so just to be sure, I'd go over your code and make sure it's all correct. If it is, post it on here, and I'll give it a look.

Link to comment
Share on other sites

Would it be down to file permissions?

 

I have just craated a test page with only the code from that link.

 

Im not getting any errors when it submits, it just refreshes the page and doesnt upload the file.

 

Curently im using xampp.

 

 

Update: SIgnore this please, it now works on the test page.

Link to comment
Share on other sites

Would it be down to file permissions?

 

I have just craated a test page with only the code from that link.

 

Im not getting any errors when it submits, it just refreshes the page and doesnt upload the file.

 

Curently im using xampp.

 

 

Update: SIgnore this please, it now works on the test page.

 

That's probably the issue solved right there. I don't think file upload forms work if you're testing it on the same computer it's getting uploaded to (I could be wrong), but if that's no the case, again, it may be your php code. I'm not talking syntax, so much as missing functions. I haven't scripted anything like that b4, so I wouldn't know what functions you'd need, but I DO know that writing permissions MUST be enabled in order for any files to be transferred into the upload folder.

 

Again, I'ma need your php code, before I can make any determinations...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.