This is a discussion on "Uploading and displaying images." within the PHP Forum section. This forum, and the thread "Uploading and displaying images. are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Uploading and displaying images.
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Uploading and displaying images.
Hi i need some help with uploading and displaying images.
I want to be able to allow users to click on a certain area of a webpage which will bring them through to another webpage which will allow them to upload an image. I then want this image to be displayed in the area that the user selected. Im not sure on how to do this. Does the image have to be uploaded to mysql Database first? Any help would be welcome. Thanks Robert |
|
|
|
|||
|
Re: Uploading and displaying images.
I am a new member, so HELLO!
I am also needing a script that can do this it would make my life so much easier, would be grateful of any help on this! Thanks in advance |
|
|||
|
Re: Uploading and displaying images.
I've got a complete worked example that uploads an image, stores it in a MySQL database, retreives it and displays it back to the browser ... here on my own website. It's one of our most popular pages
I do need to alert you that if you're going to glue all these technologies / steps together in a single application, you need to know enough about each step along the way in order to be able to split it into parts and debug it section by section along the way if it doesn't work right through - so this is NOT what I would call a "hello world" type project. But the results are great when it's running. |
|
|||
|
Re: Uploading and displaying images.
what you would do, is upload the file using php, and then i would add the path to the image (its filename) into the database.
however, you could store the binary image right in the db, up to you.. search on hotscripts for some examples.. |
|
|||
|
Re: Uploading and displaying images.
Quote:
Hope that you can help |
|
|||
|
Re: Uploading and displaying images.
Here are some of the issues that come straight to mind:
1. Change the database server, login and password in: if (! @mysql_connect("localhost","trainee","abc123")) { 2. Change the database name in: @mysql_select_db("test"); And ensure that the names database exists 3. Change the 149k top size limit to you maximum upload in: if (strlen($instr) < 149000) { and <input type=hidden name=MAX_FILE_SIZE value=150000> 4. Ensure that the database user has create privelidge 5. Ensure that the temporary upload directory exists if the server is running on a Windows platform. 6. Requires version 4.1 or later or PHP 7. Replace the default image to send out if necessary in $instr = fopen("../wellimg/ctco.jpg","rb"); $bytes = fread($instr,filesize("../wellimg/ctco.jpg")); Further comment ... you're OK (as was suggested elsewhere) to store just the file names in the database if you'll only be working with tens or hundreds or images. If you're using thousands of images, then individual files will be very slow to access in cluttered directories. Furthermore, if you keep all the data in the database you won't run the risk of a file being deleted but a database entry pointing to it remaining, nor will you run the risk of some bright spark using a file name like ../../../../cmd.exe |
|
|||
|
Re: Uploading and displaying images.
grahame i doubt that the guy will understand that.
robukni, if you have no programming experience in php, or any other languages, I would highly suggest that you DONT jump right into uploading images, working with mysql to store the paths, and how to create categories for those images (as I assume you ment by your post). Instead, learn how to work with php first, like understanding variables, functions, loops, arrays, and if you want to continue learn about objects. Then in like a few days of udnerstanding a little bit about how it works, attempt to write a upload script, or just go and download some one elses and then customize it for your site dude. If you mess up and violate some security risks with your db connections, or file submissions, it might be more headache then its worth. Its not as easy as 1 2 3, its more like 1-10 and more. Not to say its the most complicated thing, but it requires some basic knowledge of working with php and depending on what you want to do with the images (thumbnails, watermarks, etc) you will also need to know how to work with the graphics libraries. |
|
|||
|
Re: Uploading and displaying images.
I don't know much about the two enquirers - so you may be right and it may be too much, or it may be within their capabilitiy/ies directly, with a little further help from a friend or on the forum. People are often versatile, and often brighter than they're given credit for when they admit to being new in a field. I had already stated that this is NOT a "hello world" project or something like that, but to then not answer further would have closed a door on them, and on anyone else who reads this thread later (and may have a background that you feel is more appropriate).
I have two team members here at work who would never describe themselves as programmers and who adjust PHP with great care within web pages. They could almost have written the original post(s). They both have the wherewithall to get scripts like this up and running, all be it with a few extra enquiries and a bit of hand holding at times. The really advanced thing is actually in writing the script from scratch, just like when learning a foreign language, the really difficult thing is writing a paper starting with a blank sheet. Translating / understanding/ altering ain't easy, but its easier. |
|
|||
|
Re: Uploading and displaying images.
Thanks for the help, It makes sense to a point, but the only way I will find out is by trying, so once I have done I will get back to you to say how i have done, Im not well up on programming but Im also not totally dumb to it, so I will give it my best shot!
|
![]() |
| Tags |
| uploading, displaying, images |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Uploading clean images | MonaE | Graphics and 3D | 29 | Dec 10th, 2006 03:31 |
| Uploading clean images | MonaE | Web Page Design | 1 | Dec 1st, 2006 21:58 |
| Uploading Images: Help Need! | NewDesigner | Classic ASP | 0 | Oct 12th, 2006 19:08 |
| Another question about uploading images using form | AdRock | PHP Forum | 2 | Aug 2nd, 2006 08:51 |
| uploading images | benbacardi | Classic ASP | 2 | May 20th, 2005 16:15 |