PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
everytime i try to upload a file, it gives the die command "no file selected for upload" ... i dont know why this is happening , so if someone could please help and explain it would be greatly appriciated thanks
I'm sure it's not that you don't have the folder CHMODed, because it probably would give that error first. But, if you don't, make sure that you do so.
First thing that I would make note of, when using arrays, always put alphanumeric key values in quotes (ie: $_FILES['file1']['tmp_name']). Next, check out the file_upload function.
<?php
// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of $_FILES.
// In PHP earlier then 4.0.3, use copy() and is_uploaded_file() instead of move_uploaded_file
?>
That was a part that phice left off when he gave you that example from PHP.net. Make sure that you have the most updated PHP. If you cant update, try using copy() and $HTTP_POST_FILES.
If you want you can update to 4.3.2 but that should not be the problem.
I have also just recently made an upload form using POST but I used copy instead of move_uploaded_file.
First of all, I noticed some errors in form.php. Here is a corrected version.
Warning: copy(/htdocs/DPv.3/uploads/1.jpg) [function.copy]: failed to create stream: No such file or directory in c:\program files\apache group\apache\htdocs\members\release_script.php on line 4
Couldnt Upload File
that is the error in which i have gotten... well not really and error, more of a warning, but its still not uploading the file... any suggestions?
wow, it works thank you!!
another question though... i dont want to upload it to the root director... but i want to upload it to /uploads/ how would i get that to work?
is that how i would do it ? im not sure, i would try it but i have to go to sleep now... if someone could give me some guidance or some comfirmation that would be greatly appriciated. thank you!!! thanks all for replys!
thats how i did it, and it works, if there is a better way would u please post it? (the directory that is selected from the list has to already be created before uploading file or gets an error)
also if you could maybe give an example of how to check for file type (eg. .zip / .ZIP ) i would be grateful thanks you
<?
$uploadext1=".zip"
$uploadext2=".ZIP"
list($filename,$extension) = explode(".",$_FILES[file1][name]);
if($extension==$uploadext1 || $extension==$uploadext2)
{
//Upload code here . . .
}
else
{
die( "File is not the correct format, only .zip is allowed.");
}
?>
I think that should work. Check out this guide for more about file uploads.
ooops i added the ';' at the end of the variables and the script works without the error now... only problem now is that even if i upload the .ZIP file it still says wrong extention... any help ?