|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
unlink() error
Hi guys,
i am having some prob with my file uploading code and hope u guys may able to tell me whats wrong with my code my uploading file is in public_html/shopping_cart2/upload/upload.php whereas the location i wanna upload the images is public_html/shopping_cart1/myweb/images/ when i try to upload, it does copied the file to images folder but there is an error shown.. the message displayed => logo2.jpg | uploaded sucessfully! Warning: unlink(../../shopping_cart1/myfol/images/): Is a directory in /home/eonenet/public_html/shopping_cart2/upload/processFiles.php on line 27 Error: is not supported. This system only support GIF and JPEG type format images. my code: <? $uploadNeed = $_POST['uploadNeed']; // for multiple uploading // start for loop for($x=0;$x<$uploadNeed;$x++) { if($_FILES['uploadFile'. $x]['size'] > 30000) { $error = "Error: <b>".$_FILES['uploadFile'.$x]['name']."</b> is too large.<br> Your file is ".$_FILES['uploadFile'.$x]['size']."b. You are only allowed to upload files below 30000b (30kb)"; unlink("../../shopping_cart1/myfol/images/".$_FILES['uploadFile'.$x]['tmp_name']); echo $error; exit(); } if($_FILES['uploadFile'. $x]['size'] = 0) { $error = "Error: <b>".$_FILES['uploadFile'.$x]['name']."</b> is not valid.<br> Your file is ".$_FILES['uploadFile'.$x]['size']."b. You are only allowed to upload files below 30000b (30kb)"; unlink("../../shopping_cart1/myfol/images/".$_FILES['uploadFile'.$x]['tmp_name']); echo $error; exit(); } $ext = strtolower(strstr($_FILES['uploadFile'.$x]['name'],".")); if($ext != ".gif" && $ext != ".jpg" && $ext !=".jpeg") { $error = "Error: <b>".$_FILES['uploadFile'.$x]['name']."</b> is not supported. This system only support GIF and JPEG type format images."; unlink("../../shopping_cart1/myfol/images/".$_FILES['uploadFile'.$x]['tmp_name']); echo $error; exit(); } $file_name = $_FILES['uploadFile'. $x]['name']; // strip file_name of slashes $file_name = stripslashes($file_name); $file_name = str_replace("'","",$file_name); $copy = copy($_FILES['uploadFile'. $x]['tmp_name'], "../../shopping_cart1/myfol/images/$file_name"); // check if successfully copied if($copy) { echo "$file_name | uploaded sucessfully!<br><br>"; } else { echo "$file_name | could not be uploaded!<br><br>"; } } // end of loop ?> Line 27 is the part where if the type of file is not supported, unlink the temporary file... since it has been copied to the folder i want, why it still got this error ?? did i use the unlink function correctly ?? by the way, is the temporary file is stored in the images folder i wanna save or the location where my upload.php file located ?? why it works fine when i copied the image into the same folder in upload.php file (before insert the ../../shopping... string in the unlink() ) but not working after i amend the code in order to copy to other folder ? please advise. |
|
#2
|
||||
|
||||
|
The error message indicates that you're trying to unlink a directory, which won't work. That would seem to suggest that the filename isn't coming across correctly to the unlink() command. Try printing out the string you're passing to unlink() and make sure everything's coming across.
|
|
#3
|
|||
|
|||
|
hi guys,
how can i do that ?? i mean how can i actually print out the string that i am passing to unlink ??? is there anyway i can check what parameter i should put in my unlink function ??? please advise. Leong |
|
#4
|
||||
|
||||
|
Print it out the same way you pass it:
PHP Code:
If your variables aren't coming across correctly, printing them out will show you and you'll know to make adjustments in how you retrieve your variables. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > unlink() error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|