Reputation: 934
I can't move the pdf file that I uploaded using the name of the pdf file.
My server running IIS.
$file[0] = BOL_BLNUM_COMPANY_TIMESTAMP.pdf
this is the pdf file that I'm trying to move to thhe path: /AMS/BOL
.
Here is my sample code:
$file = $_FILES['pdf']['name']; $BOL = explode('_', $file[0]); $PL = explode('_', $file[1]); $INVOICE = explode('_', $file[2]); if($BOL[0] == 'BOL'){ $uploaddir = "/AMS/BOL"; $uploadfile = basename( $file[0]) ; $ok=1; $file_type=$_FILES['pdf']['type'][0]; echo $file[0]; //die(); if ($file_type=="application/pdf") { if(move_uploaded_file($file[0], $uploaddir.$uploadfile)) { echo 'File uploaded'; } else { echo "Problem uploading file"; } } }
Upvotes: 1
Views: 1259
Reputation: 2190
I think you have to use the tmp_name in move_uploaded_file function instead of name.
move_uploaded_file($_FILES['pdf']['tmp_name'], $uploaddir.$uploadfile)
Hope this helps.
Upvotes: 2