BarneyJoe Posted December 20, 2006 Share Posted December 20, 2006 Hope someone can help with this.At the moment I have a form that includes an image upload, along with various other fields that get dumped into a database.The file name is dumped into a File_Name field also, and currently trims it so that only the filename goes into the database rather than the full path, ie image.jpg instead of c:/pictures/image.jpgHowever, we've just noticed an issue whereby truncation is also taking place after the ' character.ie c:/pictures/bob's photo is dumping s photo instead of bob's photo.I can't see anything obvious in the code, but find below some snippets :The upload to server code :[code=php:0]if ( is_uploaded_file($_FILES['uploadFile']['tmp_name']) ) { $destpath = 'Photos/' . basename($_FILES['uploadFile']['name']); if (!move_uploaded_file($_FILES['uploadFile']['tmp_name'], $destpath) ) { echo 'Error moving file ' . $_FILES['uploadFile']['tmp_name'] . ' to ' . $destpath; }}[/code]The dump fields into database code :[code=php:0]$FTG_uploadFile = AddSlashes($FTGuploadFile);$FTG_Title = AddSlashes($FTGTitle);$FTG_Link_ID = AddSlashes($FTGLink_ID);$FTG_Supplier = AddSlashes($FTGSupplier);$FTG_Rights = AddSlashes($FTGRights);$FTG_Rights_Details = AddSlashes($FTGRights_Details);$FTG_Credit = AddSlashes($FTGCredit);$FTG_Image_Size = AddSlashes($FTGImage_Size);$FTG_Orientation = AddSlashes($FTGOrientation);$FTG_Year = AddSlashes($FTGYear);$FTG_Country = AddSlashes($FTGCountry);$FTG_Admin = AddSlashes($FTGAdmin);$FTG_Region = AddSlashes($FTGRegion);$FTG_Easting = AddSlashes($FTGEasting);$FTG_Northing = AddSlashes($FTGNorthing);$mysql_link = @mysql_connect("localhost", "root", "Fishnish");if (mysql_errno() == 0) { @mysql_select_db("photolibrary", $mysql_link);}if (mysql_errno() == 0) { $sqlcmd = "INSERT INTO photos(Photo_File, Title, Link_ID, Supplier, Rights, Rights_Details, Credit, Image_Size, Orientation, Year, Country, Admin, Region, Easting, Northing) VALUES('$FTG_uploadFile', '$FTG_Title', '$FTG_Link_ID', '$FTG_Supplier', '$FTG_Rights', '$FTG_Rights_Details', '$FTG_Credit', '$FTG_Image_Size', '$FTG_Orientation', '$FTG_Year', '$FTG_Country', '$FTG_Admin', '$FTG_Region', '$FTG_Easting', '$FTG_Northing')"; @mysql_query($sqlcmd, $mysql_link); $Photo_ID = mysql_insert_id (); }[/code]Any ideas what I need to modify / add to stop it truncating after ' ?Cheers,Iain Link to comment https://forums.phpfreaks.com/topic/31338-truncating-a-path-when-uploading-a-photo/ Share on other sites More sharing options...
HuggieBear Posted December 20, 2006 Share Posted December 20, 2006 I personally wouldn't be interested in finding out why it's doing it, I'd be concentrating on creating file names that don't contain apostrophes in the first place.Maybe run [code=php:0]$_FILES['uploadFile']['name'][/code] through some checks first to make sure that it contains only alpha-numeric characters before renaming the file to it.RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/31338-truncating-a-path-when-uploading-a-photo/#findComment-145046 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.