briansgl 0 Posted March 3, 2014 Report Share Posted March 3, 2014 I am currently working on file uploads. I already know how to upload a file to a folder E.G. creating the temp folder and then the final destination folder. The scenario is: I have a user table and when a user is logged in I need him to upload a file. Does the user upload it to a folder on the site and if so how do I join the file to the user which it relates or does the user need to upload it to a table in the database and again if so how to I attach it to the user the file relates to? There are basically 2 files that I need the user to upload. one is an image and the other is a PDF file. Thanks for any help with this. Quote Link to post Share on other sites
Larry 428 Posted March 3, 2014 Report Share Posted March 3, 2014 If you're going to have a lot of users and files, I would recommend create a folder for each user and then store each uploaded file within there. Rename each file, too, using the ID from the database. So you have a 'users' table and a "files" table. The files table would reflect the user ID along with the other data. Then a file might be stored as x/y, where "x" is the user ID and "y" is the file ID. There are limits to how many things can be in a directory on some operating systems, so if you imagine having a ton of users, you'd need to create parent folders for the user folders, e.g., users_to_1000, users_to_2000, etc. Quote Link to post Share on other sites
willbun 0 Posted April 21, 2015 Report Share Posted April 21, 2015 Hello, I'm reading Chapter 10 of your book (php 6 and MYSQL 5) and tried to run the file upload_image .php and i get these errors: Warning: move_uploaded_file(../uploads/William.jpg): failed to open stream: No such file or directory in /home1/willbun/public_html/ecommerce/upload_image.php on line 28 Warning: move_uploaded_file(): Unable to move '/tmp/phpVkBh7I' to '../uploads/William.jpg' in /home1/willbun/public_html/ecommerce/upload_image.php on line 28 Could you please help. Quote Link to post Share on other sites
Larry 428 Posted April 22, 2015 Report Share Posted April 22, 2015 Have you created a writable "uploads" directory in /home1/willbun/public_html? Quote Link to post Share on other sites
willbun 0 Posted April 22, 2015 Report Share Posted April 22, 2015 Ok! It's working now. But i can't see the picture on the page. Quote Link to post Share on other sites
Larry 428 Posted April 25, 2015 Report Share Posted April 25, 2015 You can't see the picture on what page? What is the URL you're running? What is the result? Quote Link to post Share on other sites
willbun 0 Posted April 26, 2015 Report Share Posted April 26, 2015 The URL is:http://www.webdesign213.com/upload_image.php when i upload an image, i get this "The file has been uploaded!" And when i check the folder: uploads in directory in /home1/willbun/public_html I see the image. But is not showing on the above URL. Quote Link to post Share on other sites
Larry 428 Posted April 27, 2015 Report Share Posted April 27, 2015 The upload_image.php script only uploads the image. It doesn't show it. That's what images.php and show_image.php is for. Quote Link to post Share on other sites
willbun 0 Posted April 27, 2015 Report Share Posted April 27, 2015 Alright! Thanks a lot for the info... Quote Link to post Share on other sites
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.
Note: Your post will require moderator approval before it will be visible.