我是php的新手。我正在从本地上传文件到远程服务器,但是文件没有上传。我从Dreamweaver中的服务器php上传pdf文件,但文件没有上传怎么办..接下来我不想扩展.pdf我只想要pdf的名字..?
if(isset($_POST['submit']))
{
echo"Upload Only PDf File";
$fileName=$_FILES["filepdf"]["name"];
$fileSize=$_FILES["filepdf"]["size"]/2024;
$fileType=$_FILES["filepdf"]["type"];
$fileTmpName=$_FILES["filepdf"]["tmp_name"];
if($fileType=="application/pdf")
{
if($fileSize<=200)
{
$random=rand(1111,9999);
$newFileName=$random.$fileName;
$uploadPath="testUpload/".$newFileName;
if(move_uploaded_file($fileTmpName,$uploadPath))
{
echo "Successful<BR>";
echo "File Name :".$newFileName."<BR>";
echo "File Size :".$fileSize." kb"."<BR>";
echo "File Type :".$fileType."<BR>";
}
else
{
echo "Maximum upload file size limit is 200 kb";
}
}
else
{
return false;
echo "You can only upload a pdf file.";
}
<form method="post" enctype="multipart/form-data" name="myform" >
<br/>
<label>Select Category:</label>
<div class="form-group">
<?php
include('config.php');
$query1=mysql_query("select catnm from category");
?>
<select class=form-control m-b-10 name=catnm id=catnm >
<?php
echo"<option>---Select---</option>";
while($query=mysql_fetch_array($query1))
{
$selectedCat = '';
if($query[catnm] == $query4['catnm'])
{
$selectedCat = "selected";
}
echo "<option value='$query[catnm]' $selectedCat >$query[catnm]</option>";
}
?>
</select>
<br/>
<input type="text" class="form-control" id="prodnm" placeholder="Product
Name" name="prodnm" required value="<?php if(isset($query4['prodnm'])){
echo $query4['prodnm'];}?> "/>
</div>
<div class="form-group">
<textarea class="form-control" id="catdtl" name="prod_dtl"
placeholder="Product Detail" "rows="10" cols="62" required><?php
if(isset($query4['prod_dtl'])){echo $query4['prod_dtl'];} ?></textarea>
</div>
<div class="form-group">
<label for="exampleInputFile">PDF File</label>
<input type="file" id="exampleInputFile" accept="application/pdf"
name="filepdf" >
file : <?php if(isset($query4['pdf'])){
echo $query4['pdf'];} ?>
</div>
<div class="checkbox">
<label>
<input id="checkbox" type="checkbox" name="updates"
<?php if(isset($query4['downld'])) { if($query4['downld'] == 'Yes') echo
"checked='checked'"; echo $query4['downld'];}
?> />Is Downloadable <br />
</label>
</div>
<input type="text" placeholder="Date of Upload" name="date" value="<?php
if(isset($_GET['id'])){$id = $_GET['id'];echo $query4['date'];
}
else
{
echodate('d/m/Y');
}? >"id="datepicker-7">
<div style="padding-top:20px;padding-bottom:40px;width:650px;">
<input type="submit" name="submit" id="button"
onclick="madeSelection(document.getElementById('catnm'),'Please Select`
Category',event)" value="<?php if(isset($_GET['id'])){$id =
$_GET['id'];echo"Update";}else{echo"Submit";}?>"/>
<input type="button" value="cancel" onclick="window.location='index.php'"/>