fredted40x Posted March 16, 2011 Share Posted March 16, 2011 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 Quote Link to comment Share on other sites More sharing options...
jamesjmann Posted March 16, 2011 Share Posted March 16, 2011 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 http://www.reconn.us/file_uploading.html Quote Link to comment Share on other sites More sharing options...
fredted40x Posted March 16, 2011 Author Share Posted March 16, 2011 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? Quote Link to comment Share on other sites More sharing options...
litebearer Posted March 16, 2011 Share Posted March 16, 2011 Show us the form as well as the php you are trying Quote Link to comment Share on other sites More sharing options...
jamesjmann Posted March 16, 2011 Share Posted March 16, 2011 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. Quote Link to comment Share on other sites More sharing options...
fredted40x Posted March 17, 2011 Author Share Posted March 17, 2011 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. Quote Link to comment Share on other sites More sharing options...
litebearer Posted March 17, 2011 Share Posted March 17, 2011 we NEED to see your most recent form AND php code in order to help you Quote Link to comment Share on other sites More sharing options...
jamesjmann Posted March 17, 2011 Share Posted March 17, 2011 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.