upload file
Posted: Mon Jan 04, 2010 3:55 pm
I have a script that uploads a file and moves it to folder marked csv. When it runs, it says that it moves the file, but the folder it is supposed to be moved into, is always empty...
and here is the form code
The folder it is supposed to move the file into is inside the same folder that the file currently resides in.
Help as to why it is not moving the file greatly appreciated
Code: Select all
switch($_FILES['upload']['error'])
{
case UPLOAD_ERR_OK:
$ext = strtolower(pathinfo($_FILES['upload']['name'], PATHINFO_EXTENSION));
switch ($ext)
{
case 'csv':
$destfile='\csv' . basename($_FILES['upload']['name']);
$ret = move_uploaded_file($_FILES['upload']['tmp_name'], $destfile);
switch ($ret)
{
case false:
echo htmlspecialchars('Unable to move file', ENT_QUOTES, 'utf-8');
break;
default:
echo htmlspecialchars('File moved successfully', ENT_QUOTES, 'utf-8');
break;
}
break;
default:
echo htmlspecialchars('Invalid File Type', ENT_QUOTES, 'utf-8');
break;
Code: Select all
<form enctype="multipart/form-data" action="index.php" method="post">
<div>
<label for="upload">File to Be Uploaded:</label>
<input name="upload" type="file" size="45"/>
</div>
<p></p>
<div>
<input type="submit" name="file_upload" value="Upload File"/>
</div>
</form>
Help as to why it is not moving the file greatly appreciated