[PHP] + in filenames
I have a file upload field, and some filename checking code, but it breaks the code whenever a + is inside the filename it verifies space and other tags but breaks on + in the name. Anyone know a fix for this please? - Vic __ Post your free ad now! http://personals.yahoo.ca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] + in filenames
Some sample code would help, but maybe try urldecode('$filename'); RW Quoting Victor <[EMAIL PROTECTED]>: ### I have a file upload field, and some filename checking code, but it ### breaks the code whenever a + is inside the filename it verifies space ### and other tags but breaks on + in the name. Anyone know a fix for this ### please? ### ### - Vic ### ### __ ### Post your free ad now! http://personals.yahoo.ca ### ### -- ### PHP General Mailing List (http://www.php.net/) ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### -- Richard Whitney Transcend Development Producing the next phase of your internet presence. [EMAIL PROTECTED] http://xend.net 602-971-2791 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] + in filenames
Here is some sample code: $file_name = explode(".", $_FILES['picture']['name']); $name = str_replace('', '_', $file_name[0]); # check if file uploaded is good if ( !in_array($_FILES['picture']['type'], $file_type) || trim($_FILES['picture']['tmp_name']) == "" || trim($_FILES['picture']['tmp_name']) == "none" ) { echo ('You can upload a JPG or JPEG filetype only.'); exit; } # Add slashes to prevent certain errors $picture_name = strip_tags($_FILES['picture']['name']); $picture_name = addslashes($picture_name); $picture_name = str_replace("\r\n", "", $picture_name); $picture_name = str_replace(" ", "", $picture_name); ____________ -Original Message- From: Richard Whitney [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 25, 2003 5:12 PM To: Victor Cc: [EMAIL PROTECTED] Subject: Re: [PHP] + in filenames Some sample code would help, but maybe try urldecode('$filename'); RW Quoting Victor <[EMAIL PROTECTED]>: ### I have a file upload field, and some filename checking code, but it ### breaks the code whenever a + is inside the filename it verifies space ### and other tags but breaks on + in the name. Anyone know a fix for this ### please? ### ### - Vic ### ### __ ### Post your free ad now! http://personals.yahoo.ca ### ### -- ### PHP General Mailing List (http://www.php.net/) ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### -- Richard Whitney Transcend Development Producing the next phase of your internet presence. [EMAIL PROTECTED] http://xend.net 602-971-2791 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Post your free ad now! http://personals.yahoo.ca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] + in filenames
Victor! What are you trying to accomplish? Do you want to preserve the original filename? Why not give uploaded files uniformly unique names? In other words, where are the +'s coming from? So, a little more detail, please! RW Quoting Victor <[EMAIL PROTECTED]>: ### Here is some sample code: ### ### ### ### $file_name = explode(".", $_FILES['picture']['name']); ### $name = str_replace('', '_', $file_name[0]); ### ### # check if file uploaded is good ### if ### ( ### !in_array($_FILES['picture']['type'], ### $file_type) ### || trim($_FILES['picture']['tmp_name']) == "" ### || trim($_FILES['picture']['tmp_name']) == ### "none" ### ) ### { ### echo ('You can upload a JPG or JPEG filetype ### only.'); ### ### exit; ### } ### ### # Add slashes to prevent certain errors ### $picture_name = strip_tags($_FILES['picture']['name']); ### $picture_name = addslashes($picture_name); ### $picture_name = str_replace("\r\n", "", $picture_name); ### $picture_name = str_replace(" ", "", $picture_name); ### ### ________ ### ### -Original Message- ### From: Richard Whitney [mailto:[EMAIL PROTECTED]] ### Sent: Saturday, January 25, 2003 5:12 PM ### To: Victor ### Cc: [EMAIL PROTECTED] ### Subject: Re: [PHP] + in filenames ### ### Some sample code would help, but maybe try urldecode('$filename'); ### ### RW ### ### Quoting Victor <[EMAIL PROTECTED]>: ### ### ### I have a file upload field, and some filename checking code, but it ### ### breaks the code whenever a + is inside the filename it verifies ### space ### ### and other tags but breaks on + in the name. Anyone know a fix for ### this ### ### please? ### ### ### ### - Vic ### ### ### ### ### __ ### ### Post your free ad now! http://personals.yahoo.ca ### ### ### ### -- ### ### PHP General Mailing List (http://www.php.net/) ### ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### ### ### ### ### ### -- ### Richard Whitney ### Transcend Development ### Producing the next phase of your internet presence. ### [EMAIL PROTECTED] ### http://xend.net ### 602-971-2791 ### ### -- ### PHP General Mailing List (http://www.php.net/) ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### __ ### Post your free ad now! http://personals.yahoo.ca ### ### -- ### PHP General Mailing List (http://www.php.net/) ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### -- Richard Whitney Transcend Development Producing the next phase of your internet presence. [EMAIL PROTECTED] http://xend.net 602-971-2791 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] + in filenames
I DO want preserve the filenames, and the pluses come from the user (beta testers that deliberately try to hack the script) . all I want to do is make sure the the script doeasnt breack when a user uploads a file that has the + character in it's name. - Vic -Original Message- From: Richard Whitney [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 25, 2003 5:32 PM To: Victor Cc: [EMAIL PROTECTED] Subject: RE: [PHP] + in filenames Victor! What are you trying to accomplish? Do you want to preserve the original filename? Why not give uploaded files uniformly unique names? In other words, where are the +'s coming from? So, a little more detail, please! RW Quoting Victor <[EMAIL PROTECTED]>: ### Here is some sample code: ### ### ### ### $file_name = explode(".", $_FILES['picture']['name']); ### $name = str_replace('', '_', $file_name[0]); ### ### # check if file uploaded is good ### if ### ( ### !in_array($_FILES['picture']['type'], ### $file_type) ### || trim($_FILES['picture']['tmp_name']) == "" ### || trim($_FILES['picture']['tmp_name']) == ### "none" ### ) ### { ### echo ('You can upload a JPG or JPEG filetype ### only.'); ### ### exit; ### } ### ### # Add slashes to prevent certain errors ### $picture_name = strip_tags($_FILES['picture']['name']); ### $picture_name = addslashes($picture_name); ### $picture_name = str_replace("\r\n", "", $picture_name); ### $picture_name = str_replace(" ", "", $picture_name); ### ### ____________ ### ### -Original Message- ### From: Richard Whitney [mailto:[EMAIL PROTECTED]] ### Sent: Saturday, January 25, 2003 5:12 PM ### To: Victor ### Cc: [EMAIL PROTECTED] ### Subject: Re: [PHP] + in filenames ### ### Some sample code would help, but maybe try urldecode('$filename'); ### ### RW ### ### Quoting Victor <[EMAIL PROTECTED]>: ### ### ### I have a file upload field, and some filename checking code, but it ### ### breaks the code whenever a + is inside the filename it verifies ### space ### ### and other tags but breaks on + in the name. Anyone know a fix for ### this ### ### please? ### ### ### ### - Vic ### ### ### ### ### __ ### ### Post your free ad now! http://personals.yahoo.ca ### ### ### ### -- ### ### PHP General Mailing List (http://www.php.net/) ### ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### ### ### ### ### ### -- ### Richard Whitney ### Transcend Development ### Producing the next phase of your internet presence. ### [EMAIL PROTECTED] ### http://xend.net ### 602-971-2791 ### ### -- ### PHP General Mailing List (http://www.php.net/) ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### __ ### Post your free ad now! http://personals.yahoo.ca ### ### -- ### PHP General Mailing List (http://www.php.net/) ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### -- Richard Whitney Transcend Development Producing the next phase of your internet presence. [EMAIL PROTECTED] http://xend.net 602-971-2791 __ Post your free ad now! http://personals.yahoo.ca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] + in filenames
I use this: $name=strtr( $name, " ?*#$%^:+=<>/\"", "__"); Victor wrote: I DO want preserve the filenames, and the pluses come from the user (beta testers that deliberately try to hack the script) . all I want to do is make sure the the script doeasnt breack when a user uploads a file that has the + character in it's name. - Vic -Original Message- From: Richard Whitney [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 25, 2003 5:32 PM To: Victor Cc: [EMAIL PROTECTED] Subject: RE: [PHP] + in filenames Victor! What are you trying to accomplish? Do you want to preserve the original filename? Why not give uploaded files uniformly unique names? In other words, where are the +'s coming from? So, a little more detail, please! RW Quoting Victor <[EMAIL PROTECTED]>: ### Here is some sample code: ### ### ### ### $file_name = explode(".", $_FILES['picture']['name']); ### $name = str_replace('', '_', $file_name[0]); ### ### # check if file uploaded is good ### if ### ( ### !in_array($_FILES['picture']['type'], ### $file_type) ### || trim($_FILES['picture']['tmp_name']) == "" ### || trim($_FILES['picture']['tmp_name']) == ### "none" ### ) ### { ### echo ('You can upload a JPG or JPEG filetype ### only.'); ### ### exit; ### } ### ### # Add slashes to prevent certain errors ### $picture_name = strip_tags($_FILES['picture']['name']); ### $picture_name = addslashes($picture_name); ### $picture_name = str_replace("\r\n", "", $picture_name); ### $picture_name = str_replace(" ", "", $picture_name); ### ### ________ ### ### -Original Message- ### From: Richard Whitney [mailto:[EMAIL PROTECTED]] ### Sent: Saturday, January 25, 2003 5:12 PM ### To: Victor ### Cc: [EMAIL PROTECTED] ### Subject: Re: [PHP] + in filenames ### ### Some sample code would help, but maybe try urldecode('$filename'); ### ### RW ### ### Quoting Victor <[EMAIL PROTECTED]>: ### ### ### I have a file upload field, and some filename checking code, but it ### ### breaks the code whenever a + is inside the filename it verifies ### space ### ### and other tags but breaks on + in the name. Anyone know a fix for ### this ### ### please? ### ### ### ### - Vic ### ### ### ### ### __ ### ### Post your free ad now! http://personals.yahoo.ca ### ### ### ### -- ### ### PHP General Mailing List (http://www.php.net/) ### ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### ### ### ### ### ### -- ### Richard Whitney ### Transcend Development ### Producing the next phase of your internet presence. ### [EMAIL PROTECTED] ### http://xend.net ### 602-971-2791 ### ### -- ### PHP General Mailing List (http://www.php.net/) ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### __ ### Post your free ad now! http://personals.yahoo.ca ### ### -- ### 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] + in filenames
On Fri, 31 Jan 2003, Marek Kilimajer wrote: > I use this: > $name=strtr( $name, > " ?*#$%^:+=<>/\"", > "__"); > I'm hoping that double quote was a typo?? Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] + in filenames
That double quote is escaped [EMAIL PROTECTED] wrote: On Fri, 31 Jan 2003, Marek Kilimajer wrote: I use this: $name=strtr( $name, " ?*#$%^:+=<>/\"", "__"); I'm hoping that double quote was a typo?? Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] + in filenames
I'll be the first to admit I was wrong and missed that. This will work out great for me. I'm writting scripts for Realtors to upload photos to us via the web and you can only imagine what these people will include in a filename. Ed On Mon, 3 Feb 2003, Marek Kilimajer wrote: > That double quote is escaped > > [EMAIL PROTECTED] wrote: > > >On Fri, 31 Jan 2003, Marek Kilimajer wrote: > > > > > > > >>I use this: > >>$name=strtr( $name, > >>" ?*#$%^:+=<>/\"", > >>"__"); > >> > >> > >> > > > > > >I'm hoping that double quote was a typo?? > > > >Ed > > > > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php