Jump to content

array of file paths putting white space in front of filenames


dogdaynoon

Recommended Posts

Hello, i have the following code: php 5, ms server 2008, iis 7

I pass this script a csv list of file paths like so...

,C:\path\path\path\file.name,C:\path\path\anotherFile.name,C:\path\path\path\file3.file

(yes there is a leading comma in the string for some reason..)

$files = $_POST['files'];

$files = explode(',', $files)
foreach($files as $filename){
if(file_exists($filename)){

echo '":' . $filename .':"Does Exist<br />';

} else {

echo 'Sorry ":' . $filename . ':" Does Not Exist<br />';

}
}

My problem:

the first file path shows it exists and there is no white space in the string, all the file paths after the first one show like such:

 

":C:\path\path\path\file.name:" Does Exist  // 1st path (good)

": C:\path\path\anotherFile.name :" Does Not Exist

": C:\path\path\file3.file:" Does Not Exist

 

pleas note... i put the ": and :" in there to show that there is indeed a white space character in front of and behind the filepaths. EXCEPT for the last path.. there is no trailing white space there.

 

Please explain why you think the white space is being added to these and what i can do to get rid of it.

 

thanks,

dogdaynoon

 

 
 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.