Jump to content

Upload images to website.


jaykappy

Recommended Posts

Brainstorming here....

 

I have a MySQL table that has records.  I display this table in a PHP page in my website.

 

  • I want the user to click into a particular record have a navigation window appear to choose a personal image for that record from their phone/tablet/PC.
  • After selection upload the image to the website (specific folder).
  • Additionally there would be a field for that image name and path.    (image/imagename.jpg)  After the file is chosen and the image is uploaded the code then has to place the path and file name in a field of that record.
  • Save.

I can then use this image in relation to the record.  

Does that make sense...

Is this possible?

 

ONE LAST THOUGHT:  If this website is being viewed from a Phone or Tablet can I attach an image straight from the camera?

 

Read something about having to place a .htaccess page in the folders to block viewing of folders etc..

 

Any examples or thoughts would be greatly appreciated.

 

Thanks

 

Link to comment
Share on other sites

In my opinion you don't need to save the image path for you already know the path, just store the image name.

 

All you really need to do is something like:

        $this->uniqueName = 'img-' . $this->uniqueName . '.' . $this->imageExt;
        // If no errors move the image to the upload directory:
        if (!$this->imageError) {
            move_uploaded_file($this->imageTemp, 'upload/' . $this->uniqueName);
            return 'upload/' . $this->uniqueName;
        }

I store the image name without the path in a separate table and give it an unique name (you can even re-size and give it a specific image type at this time if you want). There are scripts for the .htaccess  to limit users what they can access to that folder and that is something you should do, for no matter what you do in php it can be easily defeated by a script kiddy. :pirate:

Link to comment
Share on other sites

If I understand the previous poster - If you want to display these images in your web page, then you have to store them in the web-accessible tree. The security issue is that they are then reachable and you may not want that. Setting the .htaccess file can control that, so he is telling you to work on that side of things.

 

You'll have to do some googling on htaccess files.

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.