Jump to content

Users uploading images


Yesideez

Recommended Posts

I'm creating a site where users can upload three pics for their profiles. In the past I've made it so they supply a link to an image stored elsewhere and the site links to it. What I'd like to do instead is have it so they store their images on the server instead.

Should they be uploaded into the database or uploaded into a folder on the server instead?

I have written a script to allow users to upload files in the past but I need to be able to check that the file is in fact a valid image (JPEG or GIF) and not a script. If anyone can post some code on how to do this or even link me to a script that does it I'd be extremely grateful.

I'm also interested to know any security precautions I should take when allowing users to upload to the server as I've heard some stories of hackers getting in and erasing all the images - what CHMOD access should the folders be set to? I'm considering having the users upload into their own folders which my scripts would create when they create their accounts.

Many thanks.
Link to comment
Share on other sites

I don't know of any PHP examples, but I would discourage storing the images in the DB unless you have a really good reason.  It's much better to use the FS directly.  As for security, provided the files are in a non-executable directory, you should be fine -- though a serve script solves many problems as well.
Link to comment
Share on other sites

Just read this and have a question on file uploads.  I have a form that people upload information on engine failures in it, and I want them to be able to add images as well.  If I understand what you are saying, I should save the images themselves to a file (example a folder called images) on the server, and then just have a name of the image on the DB itself.  I would then be able to call up these images when the file with the rest of the data is opened in a form?

Thanks,

Ken
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.