
December 9th, 2006, 03:07 PM
|
|
Registered User
|
|
Join Date: Apr 2007
Posts: 22,310
Time spent in forums: < 1 sec
Reputation Power: 29
|
|
|
Warning: unlink() [function.unlink]: Permission denied
Hi There,
How do I fix this error?
Warning: unlink() [function.unlink]: Permission denied
I am writing a form upload script for my website. I get this error when submit a blank field. My code is below. I've tried searching Google cant find anything useful. I am developing locally on my windows machine.
php Code:
Original
- php Code |
|
|
|
<?php if (isset($_POST['submitted'])) { if (isset($_FILES['upload'])) { $allowed = array ('text/plain', 'application/msword', 'application/pdf'); if (in_array($_FILES['upload']['type'], $allowed)) { // Move File if (move_uploaded_file($_FILES['upload']['tmp_name'], "manuals/{$_FILES['upload']['name']}")) { echo '<h3 align="center">Success</h3>'; echo '<p class="error"><b>File Uploaded</b></p>'; } else { echo '<p><font color="red">The file could not be uploaded because: </b>'; switch ($_FILES['upload']['error']) { case 1: print 'The file exceeds the upload_max_filesize setting in php.ini.'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.'; break; case 3: print 'The file was only partially uploaded.'; break; case 4: print 'No file was uploaded.'; break; case 5: print 'No temporary folder was available.'; break; default: print 'A system error occurred.'; break; } } } else { echo '<h3 class="error">Error</h3>'; echo '<p class="error">Microsoft WORD Documents and PDFs Only.</p>'; unlink ($_FILES['upload']['tmp_name']); } } } ?> <form enctype="multipart/form-data" action="<?=$PHP_SELF?>" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="524288"> <fieldset> <legend>Upload Document:</legend> <p> <label for="upload">File:<em class="required"> (Required)</em></label> <input class="file" name="upload" id=upload type="file"> <input class="uploadbutton" type="submit" name="submit" value="Upload"> <input type="hidden" name="submitted" value="TRUE"> </fieldset> </form> </body> </html>
|