![]() |
Image Uploading
I am trying to make an image upload script. This script needs to upload the image to a specific folder within the site, then write its info to mysql. I've searched and searched, done alot of reading however almost everything I've looked at is different from each other. Can anyone help me in the right direction with finding the correct way of doing this? I'm still trying to understand php and this project has confused the hell out of me. Any help will be greatly appreciated.
|
I can use this too. I hope someone offers you some info soon.!!!
|
1 Attachment(s)
Here you go guys. A nice simplified example for you both. You don't have to check the extension, but it's most certainly advisable, so I've added it in for you. Simply add the extensions to the array and voila!
Any explanations needed, just ask :-) ! Ensure you create the "uploads" folder, else the script will fail -- gracefully, of course. |
I have an error from the code you provided.
Error as follows: Fatal error: Uncaught exception 'Exception' with message 'Image "8-28-2008 001.jpg" could not be uploaded.' in /var/www/vhosts/domain.com/httpdocs/admin/image_handler.php:31 Stack trace: #0 {main} thrown in /var/www/vhosts/domain.com/httpdocs/admin/image_handler.php on line 31 |
check the permissions of the uploads folder
|
Permission are 777 and still have the error.
|
Remove the "at" sign (@) from the front of move_uploaded_file. That way you'll be able to see the raw PHP error of what's happening. That should tell you a bit more than my custom exception.
|
I took the @ out and made one small change and it worked. Small error on my part, needed to change path out of one folder to go into the uploads folder. Thanks alot for that script. Now I need to get working on making it the info to the db. Thanks again...
|
Ok, I was hoping I wouldn't have to do this. When the script runs, it uploads then writes to the table... Problem is when it writes the name of the image, its writing it as Object id #1. Any thoughts?
|
Spoke to soon and didn't stare at it enough. Got it working now. Thanks for everything
|
I got a quick question for you Wildhoney. My fried had a resize script laying around but does know how to use it. How would I implement it into the script you gave me?
PHP Code:
|
You would drop it into a function. However, you may use my function in which I use to resize the images. I'm not saying mine is better, as it's been a while since I wrote it, but I know how it works :-) !
You would call it like so: php Code:
The function: php Code:
|
Hello, I am having an issue with this script. I have not changed the code at all. I simply uploaded it and I got a parsing error here:
Parse error: parse error in /usr/local/apache/upload.html on line 17 I have my apache parsing HTML as PHP so I don't think that is the issue since the rest of my site works with HTML extension. Just to make sure I renamed it back to .php and still got the error. This is line #17: Code:
/* Ensure the extension we're upload is allowed. */throw new Exception('Extension "' . $szExtension . '" has been disallowed.'); Any idea's? |
Also one more question, should the UPLOAD directory be in a publicly accessible directory or in a private directory?
I'm not sure what the security concerns are? |
| All times are GMT. The time now is 12:01 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0