jaykappy Posted June 24, 2013 Share Posted June 24, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/279514-upload-images-to-website/ Share on other sites More sharing options...
ginerjm Posted June 24, 2013 Share Posted June 24, 2013 This is all do-able, although I don't know what the apache reference means. Google can help you. Try it. Quote Link to comment https://forums.phpfreaks.com/topic/279514-upload-images-to-website/#findComment-1437675 Share on other sites More sharing options...
Strider64 Posted June 24, 2013 Share Posted June 24, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/279514-upload-images-to-website/#findComment-1437689 Share on other sites More sharing options...
jaykappy Posted June 25, 2013 Author Share Posted June 25, 2013 Strider64..... So what do I do to secure this? What are you referring to that can easily be hacked? Can you explain a bit further... Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/279514-upload-images-to-website/#findComment-1437842 Share on other sites More sharing options...
ginerjm Posted June 25, 2013 Share Posted June 25, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/279514-upload-images-to-website/#findComment-1437847 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.