I want to upload files in PHP. I wrote
You are a long way from a working script
You can try
800*1024) {
$errors [] = "File Too large";
}
if (! is_writable ( $savePath )) {
$errors [] = "File Destination not writeable";
}
$fileDst = $savePath . DIRECTORY_SEPARATOR . $fileName;
$filePrifix = basename ( $fileName, "." . $fileExt );
$i = 0;
while ( file_exists ( $fileDst ) ) {
$i ++;
$fileDst = $savePath . DIRECTORY_SEPARATOR . $filePrifix . "_" . $i . "." . $fileExt;
}
if (count ( $errors ) == 0) {
if (@move_uploaded_file ( $fileTemp, $fileDst )) {
$output['STATUS'] = "OK";
$output['TYPE'] = $fileType;
$output['Size'] = $fileSize;
$output['Destination'] = $fileDst;
} else {
$errors [] = "Error Saving File";
}
}
if(count($errors) > 0)
{
echo "Upload Error
" ;
foreach ($errors as $error)
{
echo $error , "
" ;
}
}
else
{
echo "File Uploaded
" ;
foreach ($output as $key => $value)
{
echo $key , ":" , $value , "
" ;
}
}
}
?>