RE: [PHP] image uploads
Don't mistake client side cache with FS / WebServer cache. Also, take into consideration that getting an image from FS is much More efficient than from MySQL so why go there? As for order, that's really not a problem as you can build a simple Directory hierarchy such as : /home/MySite/images/b/be/berber.gif We handle more than 20M images and files with no problem this way. berber -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 01, 2006 4:23 PM To: php-general@lists.php.net Cc: Kevin Waterson Subject: Re: [PHP] image uploads Hi gang: I don't mean to offend anyone, but I'm going to side with Keith Waterson about storing images in a dB rather than in a file system. My reasons are pretty simple. First, an image is nothing more than a large of string text -- sure it's voluminous, but there's no difference how it is stored -- either in a dB or fs, it's still all just 1's and 0's stored on a hard drive. Second, when you search MySQL, you're not searching blobs (hopefully) -- instead you are searching the index. What is attached to the index has NO effect on a search. Third, MySQL search routines are simply binary-trees. The indexes are simply pointers to the data stored on a hard drive -- no more, no less than placing url's in a dB and using those as "pointers" to the image stored on a file system -- which may actually take more time resolve. Forth, with respect to the argument of caching the images, your browser doesn't know how images are provided. The image is coming from a simple tag or a header file and the browser simply looks at what's there and compares it with what it has and loads the image accordingly. If you want to store your images in a file system, then that's fine -- but as the number of those images climb, you're going to need a way to organize and handle those images -- and that sounds like a problem that a dB can solve. I can understand image storage being something somewhat problematic. It's not abundantly clear what is actually going on when you store an image. People have impressions that BLOBs are huge attachments that "slow" down dB operations because of their size and when you delete one, there's a huge hole left in your dB. But, those are just unfounded fears, which IMO are reenforced by people's problematic experiences in trying to get things to work. For example, I have read numerous times in the archives and on the net that there is no way to consolidate a MySQL dB after you have deletions. The holes in your dB will remain. But that's not true, while it may not be the best to consolidate a table, it can be done with a single line of code. It's claims like this that add to the confusion of how you can use MySQL and thus create the illusion that you shouldn't use MySQL to store images. But, until someone provides me concrete evidence that MySQL can't handle images as well, or better than a file system, then I'll consider the claim to be an urban myth based upon people not really understanding MySQL. tedd -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image uploads
Richard Lynch wrote: On Tue, January 31, 2006 4:43 pm, tedd wrote: Storing the image in the DB is probably not a Good Idea for a variety of reasons. And they are? ... in the archives. http://marc.theaimsgroup.com/?l=php-general Richard, are you feeling okay? I don't think I've ever seen a post from you this short. ;) -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image uploads
Hi gang: I don't mean to offend anyone, but I'm going to side with Keith Waterson about storing images in a dB rather than in a file system. My reasons are pretty simple. First, an image is nothing more than a large of string text -- sure it's voluminous, but there's no difference how it is stored -- either in a dB or fs, it's still all just 1's and 0's stored on a hard drive. Second, when you search MySQL, you're not searching blobs (hopefully) -- instead you are searching the index. What is attached to the index has NO effect on a search. Third, MySQL search routines are simply binary-trees. The indexes are simply pointers to the data stored on a hard drive -- no more, no less than placing url's in a dB and using those as "pointers" to the image stored on a file system -- which may actually take more time resolve. Forth, with respect to the argument of caching the images, your browser doesn't know how images are provided. The image is coming from a simple tag or a header file and the browser simply looks at what's there and compares it with what it has and loads the image accordingly. If you want to store your images in a file system, then that's fine -- but as the number of those images climb, you're going to need a way to organize and handle those images -- and that sounds like a problem that a dB can solve. I can understand image storage being something somewhat problematic. It's not abundantly clear what is actually going on when you store an image. People have impressions that BLOBs are huge attachments that "slow" down dB operations because of their size and when you delete one, there's a huge hole left in your dB. But, those are just unfounded fears, which IMO are reenforced by people's problematic experiences in trying to get things to work. For example, I have read numerous times in the archives and on the net that there is no way to consolidate a MySQL dB after you have deletions. The holes in your dB will remain. But that's not true, while it may not be the best to consolidate a table, it can be done with a single line of code. It's claims like this that add to the confusion of how you can use MySQL and thus create the illusion that you shouldn't use MySQL to store images. But, until someone provides me concrete evidence that MySQL can't handle images as well, or better than a file system, then I'll consider the claim to be an urban myth based upon people not really understanding MySQL. tedd -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image uploads
This one time, at band camp, "Richard Lynch" <[EMAIL PROTECTED]> wrote: > On Tue, January 31, 2006 4:43 pm, tedd wrote: > >>Storing the image in the DB is probably not a Good Idea for a variety > >>of reasons. > > > > And they are? > > ... in the archives. > > http://marc.theaimsgroup.com/?l=php-general Rubbish. Storing images in the db is just as viable as within the fs. What is a file system if not a database? Most of the horror stories surrounding binary storage in BLOBs come from the use of database's that have no _true_ BLOB, like pgsql which uses a secondary database (r-tree) index portions of the image and then stitch them back together when SELECTed. Also many coders are at fault when doing things like SELECT * FROM image_table when all they need is the image name of image_id. My own benchmarks have shown MySQL to be on par with file system storage and the method of using the db to store the url proved to be the SLOWEST. Lets see... using this file AB gives this result Time taken for tests: 44.576146 seconds Complete requests: 10 Failed requests:23 (Connect: 0, Length: 0, Exceptions: 23) Write errors: 0 Non-2xx responses: 100023 Total transferred: 49911477 bytes HTML transferred: 30406992 bytes Requests per second:2243.35 [#/sec] (mean) Time per request: 0.446 [ms] (mean) Time per request: 0.446 [ms] (mean, across all concurrent requests) Transfer rate: 1093.43 [Kbytes/sec] received 44.5 seconds over 100,000 accesses when using the file system Now, using the db to store the url and the image in the file system... '; } // close the db link mysql_close($link); ?> AB gives this result... Time taken for tests: 45.793727 seconds Complete requests: 10 Failed requests:1 (Connect: 0, Length: 0, Exceptions: 1) Write errors: 0 Non-2xx responses: 11 Total transferred: 50300503 bytes HTML transferred: 30800308 bytes Requests per second:2183.71 [#/sec] (mean) Time per request: 0.458 [ms] (mean) Time per request: 0.458 [ms] (mean, across all concurrent requests) Transfer rate: 1072.66 [Kbytes/sec] received 45.8 seconds over 100,000 accesses Now, using the database to store the image AB reports the following.. Time taken for tests: 45.206154 seconds Complete requests: 10 Failed requests:0 Write errors: 0 Non-2xx responses: 10 Total transferred: 5020 bytes HTML transferred: 3070 bytes Requests per second:2212.09 [#/sec] (mean) Time per request: 0.452 [ms] (mean) Time per request: 0.452 [ms] (mean, across all concurrent requests) Transfer rate: 1084.43 [Kbytes/sec] received 45.2 seconds. Faster than the image/url method and about 0.15 seconds slower than the file system method. Of course, greater speeds can be gained should you store the database on a RAW partition and thus eliminate further file system overhead. Happy hunting. Kevin -- "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image uploads
William Stokes wrote: "Do you really want people uploading 2.5MB a shot to your server?" No. Not really. It's just modern digicams... Most people don't know how to edit pics or doesn't have right tools for that. And they don't realize the difference between 2.5Mb or 0.5Mb just as long there are atleast 5Megapixels in the camera :( Well at least let them know that ^_^ It's the users problem if he wants to upload a 50gig file. If tell him that he will take ages for it and complain afterwards, you can say you told him. Users are oftenly not that dumb. You just have to tell them what to do, and they will find a way ^_^ ""Albert"" <[EMAIL PROTECTED]> kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: I somehow got it back working with Opera. Don't know how :) One question still remains. How to make 100% sure that the image isn't re-loaded to server if user hits "refresh"? And he will cause it can take long time to upload 2.5Mb pics over a slow link. use the header ("Loacation:"); function or Meta-refresh to automatically reload the page, so even if he hits then refresh, the image is not beeing sent. Greets Barry -- Smileys rule (cX.x)C --o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image uploads
"Do you really want people uploading 2.5MB a shot to your server?" No. Not really. It's just modern digicams... Most people don't know how to edit pics or doesn't have right tools for that. And they don't realize the difference between 2.5Mb or 0.5Mb just as long there are atleast 5Megapixels in the camera :( ""Albert"" <[EMAIL PROTECTED]> kirjoitti viestissä:[EMAIL PROTECTED] > William Stokes wrote: >> I somehow got it back working with Opera. Don't know how :) One question >> still remains. How to make 100% sure that the image isn't re-loaded to >> server if user hits "refresh"? And he will cause it can take long time to >> upload 2.5Mb pics over a slow link. > > When you hit refresh/reload in the browser then the browser send the data > to > the server again. No way around this. You can make sure that you do > nothing > with the data received by follow the uniqid() method described earlier. > > Do you really want people uploading 2.5MB a shot to your server? Why not > limit it to 512KB? > > Albert > > > > -- > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.1.375 / Virus Database: 267.14.25/247 - Release Date: > 2006/01/31 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] image uploads
William Stokes wrote: > I somehow got it back working with Opera. Don't know how :) One question > still remains. How to make 100% sure that the image isn't re-loaded to > server if user hits "refresh"? And he will cause it can take long time to > upload 2.5Mb pics over a slow link. When you hit refresh/reload in the browser then the browser send the data to the server again. No way around this. You can make sure that you do nothing with the data received by follow the uniqid() method described earlier. Do you really want people uploading 2.5MB a shot to your server? Why not limit it to 512KB? Albert -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.14.25/247 - Release Date: 2006/01/31 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image uploads
OK. I was a bit vague at the first posting... To DB a put the filepath to the two images i create. And some additional info like upload date, width, height etc. I like storing my files in filesystem... "You mean isset($image), right?..." Right ! "ENCTYPE="multipart/form-data" " It's there. I somehow got it back working with Opera. Don't know how :) One question still remains. How to make 100% sure that the image isn't re-loaded to server if user hits "refresh"? And he will cause it can take long time to upload 2.5Mb pics over a slow link. Thanks again -Will ""Richard Lynch"" <[EMAIL PROTECTED]> kirjoitti viestissä:[EMAIL PROTECTED] > On Tue, January 31, 2006 4:43 pm, tedd wrote: >>>Storing the image in the DB is probably not a Good Idea for a variety >>>of reasons. >> >> And they are? > > ... in the archives. > > http://marc.theaimsgroup.com/?l=php-general > > -- > Like Music? > http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image uploads
On Tue, January 31, 2006 4:43 pm, tedd wrote: >>Storing the image in the DB is probably not a Good Idea for a variety >>of reasons. > > And they are? ... in the archives. http://marc.theaimsgroup.com/?l=php-general -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] image uploads
The main reason I don't like storing the images in the DB is because File system is much more fast then DB. FS and the web server know How to cache images while using the DB makes you access the DB for each and every picture. It's also harder to maintain cause you don't have a physical file you can Move from place to place or from dir to dir. Or just look at a bunch of Random images like you would in a directory. >From my point of view there has to be a very good reason to put images Inside a DB instead of in the file system. Sincerely berber Visit the Weber Sites Today, To see where PHP might take you tomorrow. Free Uptime Monitor : http://uptime.weberdev.com PHP content for your site : http://content.weber-sites.com -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 01, 2006 12:43 AM To: php-general@lists.php.net Subject: Re: [PHP] image uploads Richard said: >Storing the image in the DB is probably not a Good Idea for a variety >of reasons. And they are? tedd -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image uploads
Richard said: Storing the image in the DB is probably not a Good Idea for a variety of reasons. And they are? tedd -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image uploads
On Tue, January 31, 2006 10:58 am, William Stokes wrote: > Is there something special about php and images that nobody told me... No. :-) > I'm writing a image gallery but I have run to serious trouble with > it. I > have one page with form in it. Form's action is $PHP_SELF. In the form > there > is just one file field called "image". Add the ENCTYPE="multipart/form-data" to the FORM tag, if you don't have it. > I test if there's users image to handle with > if (isset($img)) You mean isset($image), right?... The name above is "image"... Post source code snippets. > if there's one. I greate two new images using > > imagecreatefromjpeg() > imagecreatetruecolor() > imagecopyresampled() > > in two different functions. At the end of both functions there's > imagedestroy($img). After that the both image information is stored to > DB Storing the image in the DB is probably not a Good Idea for a variety of reasons. There is a highly-optimized much more mature specialized database specifically designed for large-file operations (LFO)... It's called "the file system" :-) > and, if succeful, at the end I do unset($img) to clear the old image > variable from memory. Both new images are created OK and DB update > works OK. OK... > But nothing else doesn't work. You'd have to give us a lot more than "doesn't work"... We've got nothing to work on here. > I don't know what I have to do to > prevent the > image from realoading to server second time if user hits browser > refresh > button. The same image is uploaded every time the user hits refresh. Well, yeah, if they upload the same image again, then you're going to get it again. If you don't want to allow that, then include a unique token http://php.net/uniqid in the form you send them, and when they upload the first image, mark that token as "used" and don't let them do it again. You could also do a binary-safe string comparison of the new image with the images already in the database -- That would be slower, but would dis-allow somebody from filling out the form again with a new token and uploading the same image a second time. > Another > thing is that Opera stopped co-operation with this page once and for > all. It > just freezes after the page call's itself. IE and Firefox doesn't. Opera freezing up is probably a separate problem entirely. Ignore it until you get the application working the way you want it to work. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] image uploads
Check this out : http://www.weberdev.com/get_example-3938.html Image Upload And Resize Script Sincerely berber Visit the Weber Sites Today, To see where PHP might take you tomorrow. PHP & MySQL Forums : http://www.weberforums.com Learn PHP & MySQL Playing Trivia : http://www.webertrivia.com -Original Message- From: William Stokes [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 31, 2006 6:58 PM To: php-general@lists.php.net Subject: [PHP] image uploads Hello, Is there something special about php and images that nobody told me... I'm writing a image gallery but I have run to serious trouble with it. I have one page with form in it. Form's action is $PHP_SELF. In the form there is just one file field called "image". I test if there's users image to handle with if (isset($img)) if there's one. I greate two new images using imagecreatefromjpeg() imagecreatetruecolor() imagecopyresampled() in two different functions. At the end of both functions there's imagedestroy($img). After that the both image information is stored to DB and, if succeful, at the end I do unset($img) to clear the old image variable from memory. Both new images are created OK and DB update works OK. But nothing else doesn't work. I don't know what I have to do to prevent the image from realoading to server second time if user hits browser refresh button. The same image is uploaded every time the user hits refresh. Another thing is that Opera stopped co-operation with this page once and for all. It just freezes after the page call's itself. IE and Firefox doesn't. I Really need some help Thanks -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image uploads - part 2
On Sat, 2004-11-06 at 03:58 -0800, Jaskirat Singh wrote: > 4) database + dedicated = err.. stupid? ;) I should have clarified this more as to why I prefer the DB storage method. I don't expect that my web application will be the only interface to the data that I am storing the database. For some clients, we build pyton interfaces that clients run on their desktop. We also replicate our databases across a few servers and it's much easier to keep track of the database than it is to make sure a bunch of filesystem-stored files are too. Some of our client database machines don't have a webservers so we don't program with just the web in mind. With storing in the database, we get transaction support and we know that an image will not be deleted if it is being referenced by another piece of data. Speed versus data integrity is something we have to juggle per client as to what is more important. If you know how to optimize your database (a stock pgsql db can be rather slow..) then the speed differences are not enough of a factor for us to know that our data just a bit more safer. -Robby -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting & Development *--- Now supporting PHP5 --- / signature.asc Description: This is a digitally signed message part
Re: [PHP] Image Uploads beeing corupted
As I showed by this : http://your.domain.com/your.script.php"; Method="Post" ENCTYPE="multipart/form-data" > I can write this in a simple html, press the submit button and instead of file you will receive $ImageFile_name as a text variable. I can write in it everything but you rely on that PHP made it. No PHP didn't. Also in such form $ImageFile_tmpname can be supplied and if someone does this : The /etc/passwd file can be shown easily. My suggestion : rely on $HTTP_POST_FILES . Yes it is long to type but it's secured. Also as I said. Since the new PHP 4.1.0 there will be $_FILES array, equivalent of $HTTP_POST_FILES(which will exists also). The GD extension is used for dynamic construction of jpg,png,gif(up to some 1.x version). The constructed image can be saved to file or sent to the browser. GetImageSize() is one of the many functions provided by GD. http://www.php.net/manual/en/ref.image.php Best regards, Andrey Hristov - Original Message - From: "Ryan Stephens (Hotmail)" <[EMAIL PROTECTED]> To: "Andrey Hristov" <[EMAIL PROTECTED]> Sent: Wednesday, November 28, 2001 10:51 AM Subject: Re: [PHP] Image Uploads beeing corupted > this means nothing to me... sorry, i've only been working with PHP for a > couple weeks. and a few month of web learning. the site im working > on is hosted by some other guy, so i dont have access to it if i had to > change anything there. > > Why is $ImageFile a possible security hole? > What is GD extension? > > I dont need to find the type... i just used that as a test to see if that > might have anything to do with my corrupted file problem. And i found that > all the information beeing entered into the database re: its name and size > is fine... but it wont return a type... Im thinking if it cant return a type > (but still uploads the file) there must be a connection to it beeing > corrupt. > > Ryan > > > - Original Message - > From: "Andrey Hristov" <[EMAIL PROTECTED]> > To: "Ryan Stephens" <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Wednesday, November 28, 2001 12:46 AM > Subject: Re: [PHP] Image Uploads beeing corupted > > > > If you have GD extension build in your PHP use it to find the type(if you > are limited ot jpeg/gif/png files). > > I want to say again that the using of $ImageFile* is a possible security > hole. > > > > Regards, > > Andrey Hristov > > - Original Message - > > From: "Ryan Stephens" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, November 28, 2001 10:39 AM > > Subject: Re: [PHP] Image Uploads beeing corupted > > > > > > > the funny thing is this > > > > > > the information is beeing inserted into the database... the file is > beeing > > > uploaded (as i can see it in the directory). I can get results from > > > $ImageFile > > > $ImageFile_name > > > $ImageFile_size > > > > > > but i cant get a result for $ImageFile_type this comes up blank > > > there is obviously some connection, but just not sure what. > > > > > > Ryan > > > > > > > > > "Andrey Hristov" <[EMAIL PROTECTED]> wrote in message > > > 0b0c01c177e5$f0e15580$0b01a8c0@ANDreY">news:0b0c01c177e5$f0e15580$0b01a8c0@ANDreY... > > > > The problem is in that you do global only for $ImageFile, but not for > > > $ImageFile_name. > > > > Big flaw is that if someone make a form > > > > > > > ENCTYPE="multipart/form-data" > > > > > > > > > > > > > value="../../../../etc/passwd"> > > > > > > > > > > > > > > > > may be can make a big shot. Depends on under which user Apache is > running. > > > > The best technique is to use $HTTP_POST_FILES. Since PHP4.1.0 there > will > > > be new name > > > > for it => $_FILES .This array will be global, so there is no need to > write > > > > global $_FILES . The same is done for $_GET, $_POST, $_COOKIE. > $_REQUEST > > > is > > > > merged array of $_GET,$_POST,$_COOKIE in the order of gpc(from > php.ini). > > > > > > > > Regards, > > > > Andrey Hristov > > > > IcyGEN Corporation > > > > http://www.icygen.com > > > > BALANCED SOLUTIONS > > > > > > > > > > > > - Original Message - > > > > From: "Ryan Stephens" <[EMAIL PROTECTED]>
Re: [PHP] Image Uploads beeing corupted
If you have GD extension build in your PHP use it to find the type(if you are limited ot jpeg/gif/png files). I want to say again that the using of $ImageFile* is a possible security hole. Regards, Andrey Hristov - Original Message - From: "Ryan Stephens" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, November 28, 2001 10:39 AM Subject: Re: [PHP] Image Uploads beeing corupted > the funny thing is this > > the information is beeing inserted into the database... the file is beeing > uploaded (as i can see it in the directory). I can get results from > $ImageFile > $ImageFile_name > $ImageFile_size > > but i cant get a result for $ImageFile_type this comes up blank > there is obviously some connection, but just not sure what. > > Ryan > > > "Andrey Hristov" <[EMAIL PROTECTED]> wrote in message > 0b0c01c177e5$f0e15580$0b01a8c0@ANDreY">news:0b0c01c177e5$f0e15580$0b01a8c0@ANDreY... > > The problem is in that you do global only for $ImageFile, but not for > $ImageFile_name. > > Big flaw is that if someone make a form > > > ENCTYPE="multipart/form-data" > > > > > > > > > > > > > > > may be can make a big shot. Depends on under which user Apache is running. > > The best technique is to use $HTTP_POST_FILES. Since PHP4.1.0 there will > be new name > > for it => $_FILES .This array will be global, so there is no need to write > > global $_FILES . The same is done for $_GET, $_POST, $_COOKIE. $_REQUEST > is > > merged array of $_GET,$_POST,$_COOKIE in the order of gpc(from php.ini). > > > > Regards, > > Andrey Hristov > > IcyGEN Corporation > > http://www.icygen.com > > BALANCED SOLUTIONS > > > > > > - Original Message - > > From: "Ryan Stephens" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, November 28, 2001 10:12 AM > > Subject: [PHP] Image Uploads beeing corupted > > > > > > > Hey guys, > > > > > > I got my uploads to work thanks to some peoples help here in this > > > newsgroup but now im having a problem with the files beeing > corrupted > > > upon upload. not sure why any help would be greatly apreciated. > > > > > > I have included my code again if it helps any. > > > > > > <> > > > function UploadImage(){ > > > global $HTTP_POST_FILES; > > > global $ImageFile; > > > reset($HTTP_POST_FILES); > > > $pic_file = $HTTP_POST_FILES['ImageFile']; > > > copy ($pic_file['tmp_name'], "../images/$ImageFile_name"); > > > } > > > > > > > > ENCTYPE="multipart/form-data" > > > > > > > > > > > > > > > > > > > <> > > > > > > I've found that just doing this seems to do the same > > > > > > function UploadImage(){ > > > global $ImageFile; > > > copy ($ImageFile, "../images/$ImageFile_name"); > > > } > > > > > > > > > Thanks > > > Ryan Stephens > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Image Uploads beeing corupted
the funny thing is this the information is beeing inserted into the database... the file is beeing uploaded (as i can see it in the directory). I can get results from $ImageFile $ImageFile_name $ImageFile_size but i cant get a result for $ImageFile_type this comes up blank there is obviously some connection, but just not sure what. Ryan "Andrey Hristov" <[EMAIL PROTECTED]> wrote in message 0b0c01c177e5$f0e15580$0b01a8c0@ANDreY">news:0b0c01c177e5$f0e15580$0b01a8c0@ANDreY... > The problem is in that you do global only for $ImageFile, but not for $ImageFile_name. > Big flaw is that if someone make a form > ENCTYPE="multipart/form-data" > > > > > > > > may be can make a big shot. Depends on under which user Apache is running. > The best technique is to use $HTTP_POST_FILES. Since PHP4.1.0 there will be new name > for it => $_FILES .This array will be global, so there is no need to write > global $_FILES . The same is done for $_GET, $_POST, $_COOKIE. $_REQUEST is > merged array of $_GET,$_POST,$_COOKIE in the order of gpc(from php.ini). > > Regards, > Andrey Hristov > IcyGEN Corporation > http://www.icygen.com > BALANCED SOLUTIONS > > > - Original Message - > From: "Ryan Stephens" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, November 28, 2001 10:12 AM > Subject: [PHP] Image Uploads beeing corupted > > > > Hey guys, > > > > I got my uploads to work thanks to some peoples help here in this > > newsgroup but now im having a problem with the files beeing corrupted > > upon upload. not sure why any help would be greatly apreciated. > > > > I have included my code again if it helps any. > > > > <> > > function UploadImage(){ > > global $HTTP_POST_FILES; > > global $ImageFile; > > reset($HTTP_POST_FILES); > > $pic_file = $HTTP_POST_FILES['ImageFile']; > > copy ($pic_file['tmp_name'], "../images/$ImageFile_name"); > > } > > > > > ENCTYPE="multipart/form-data" > > > > > > > > > > > > > <> > > > > I've found that just doing this seems to do the same > > > > function UploadImage(){ > > global $ImageFile; > > copy ($ImageFile, "../images/$ImageFile_name"); > > } > > > > > > Thanks > > Ryan Stephens > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Image Uploads beeing corupted
The problem is in that you do global only for $ImageFile, but not for $ImageFile_name. Big flaw is that if someone make a form may be can make a big shot. Depends on under which user Apache is running. The best technique is to use $HTTP_POST_FILES. Since PHP4.1.0 there will be new name for it => $_FILES .This array will be global, so there is no need to write global $_FILES . The same is done for $_GET, $_POST, $_COOKIE. $_REQUEST is merged array of $_GET,$_POST,$_COOKIE in the order of gpc(from php.ini). Regards, Andrey Hristov IcyGEN Corporation http://www.icygen.com BALANCED SOLUTIONS - Original Message - From: "Ryan Stephens" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, November 28, 2001 10:12 AM Subject: [PHP] Image Uploads beeing corupted > Hey guys, > > I got my uploads to work thanks to some peoples help here in this > newsgroup but now im having a problem with the files beeing corrupted > upon upload. not sure why any help would be greatly apreciated. > > I have included my code again if it helps any. > > <> > function UploadImage(){ > global $HTTP_POST_FILES; > global $ImageFile; > reset($HTTP_POST_FILES); > $pic_file = $HTTP_POST_FILES['ImageFile']; > copy ($pic_file['tmp_name'], "../images/$ImageFile_name"); > } > > ENCTYPE="multipart/form-data" > > > > > > > <> > > I've found that just doing this seems to do the same > > function UploadImage(){ > global $ImageFile; > copy ($ImageFile, "../images/$ImageFile_name"); > } > > > Thanks > Ryan Stephens > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]