Uploaded Picture Name

From: Date: Sat, 06 Dec 2003 23:02:29 +0000
Subject: Uploaded Picture Name
Groups: php.general 
Request: Send a blank email to php-general+get-172106@lists.php.net to get a copy of this message
I am having a slight problem with a picture upload script. I seems to work just fine except when the picture name has an apostrphe in the name. How do all of you deal with this problem. Do you just rename the file to something else when you upload it. Here is the script that I am using. It is called from a form using multipart/form-data. Thanks for the help. displayHeader("File Uploaded"); printf("<b>Uploaded File Details</b><br><br>"); printf("Name: %s <br>", $_FILES["photo"]["name"]); printf("Temporary Name: %s <br>", $_FILES["photo"]["tmp_name"]); printf("Size: %s <br>", $_FILES["photo"]["size"]); printf("Type: %s <br> <br>", $_FILES["photo"]["type"]); if (copy($_FILES["photo"]["tmp_name"],"{$GLOBALS['IMAGE_DIR']}/{$_FILES['photo' ]['name']}")) {printf("<b>File successfully copied</b>");} else {printf("<b>Error: failed to copy file</b>");} // Put picture path into database and assosiate with a product $query = "insert into picture (product_id, path) values ( {$_POST['product_id']}, '{$GLOBALS['IMAGE_DIR']}/{$_FILES['photo']['name']}' )"; mysql_query($query) or die (mysql_error());

« previous php.general (#172106) next »