PHP move uploadedfile, how can I upload PDF files or files with space in the name?

Mike M

New member
I have the following code, it works but it wont upload files with .pdf extension or names with space in the name, pleasehelp me

$target_path = "c:\store\";
$ntarget_path = "/store/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$name =$_FILES['uploadedfile']['name'];
//echo '[[[[['. $_FILES['uploadedfile']['name'].']]]]]]]';
if ( $_FILES['uploadedfile']['name']!=''){

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
$filesz=filesize("$target_path");

quer("select filesequence.nextval from dual");

while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS)){
$seq=$row[0];


}
$stmt = OCIParse($conn, "insert into map values ('" .$name. "','".$filesz."','".$messageid."', '".$replyid."','".$seq."')");

$m=$_FILES['uploadedfile']['name'];
rename ($ntarget_path.$m,$ntarget_path.$seq);

//echo "<br /> $seq";
echo "<br />With the following attachment <b>". basename( $_FILES['uploadedfile']['name']).
" </b>";

OCIExecute ($stmt);
OCICommit($conn);

} else{
//echo "There was an error uploading the file, please try again!";
}
}
 
Back
Top