Jump to content
Sign in to follow this  
MarkT

PHP File Upload - How Does it Work?

Recommended Posts

Hello,

Can anyone show me a demo of a code, I'm looking for a form that uses text and file upload.

I need a form that has details such as title and content, but I also want an image upload where it saves the file to my FTP server in a folder called Uploads and then it saves the filename and extension to the database, along with the other details from the form.

 

Can anyone give me the code and explain it please!

 

Thanks in advance.

Share this post


Link to post
Share on other sites

I've tried, but the file upload script is confusing me, Can you explain it please? Where to put details/upload directory etc.

Share this post


Link to post
Share on other sites

The "Saving the Uploaded File" example shows how to save the file. You use the move_uploaded_file function to save it where you want. As for the other fields in the form, those are just normal form fields that will have their values submitted via $_POST.

 

http://www.php.net/manual/en/function.move-uploaded-file.php

Share this post


Link to post
Share on other sites

Alright,

I get the code.

 

But how do I set my SQL query to save the filename in the database?

Share this post


Link to post
Share on other sites

I'm not sure which part you're missing. If you have the filename, then just add it to the query the same way you would add any other string. Have you worked with databases before?

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...