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!
hello everyone,
I am fairly new to these functions, I am trying to create a folder on my server using the mkdir function using an item name from the database which works fine, but i have trouble using move_uploaded_file() to then copy a php file from a form to the newly created folder, I have done some reading and i think the problem is because i have created the folder from an admin page , the user who created the folder user is 30 , which creates the problem.
How can i fix the problem , is it possible to create a folder from the admin page and then copy a file to the folder?
thanks for any help in advance. code i have pasted below.
hi, thats fine the folder is already 0777, there are no permission problems. I think the problem is because i created the folder through the admin website and not directly from an ftp program. Usually i get when i create folders through ftp i get owner 711, when i create using the script i get owner 30. so i think it doesnt let me move a file to the dynamic created folder (owner 711) . thanks for the advice
Could be wrong but it might not be able to move the file as appears the script is trying to move a file which has an open file pointer. (i.e. fopen but no fclose, unless I missed it?)
Personally, I'd also throw a bit more error checking in there too.
that could be, mm i dont know how to close it though , how would that be done? I have used the script before to upload images to folders that i created using ftp and there were no problems... also error checking , what code can i add for that... thanks
YES!!!! thats was it , using $file_handle = fclose($_FILES["file"]["tmp_name"], "rb"); to close it worked fine!!! greate bruv you helped me alot of time and stress, thanks so much
vanceibz wrote:YES!!!! thats was it , using $file_handle = fclose($_FILES["file"]["tmp_name"], "rb"); to close it worked fine!!! greate bruv you helped me alot of time and stress, thanks so much
DAmn, no mate it didnt work , i thought it did! but i was looking at the wrong folder, if i change the script to move the file to a folder that i created using ftp it works but not to a dynamically created one.
yea, i have moved fclose() i hope its looks ok there, the permissions for the created folder are 777 , the strange thing is owner 30, which i think is the problem maybe i cant create a new file with owner 30 in a folder with owner 30, dont know??¿
It would seem a bit odd that a user can create a directory but not write to it.
You could try the code I posted here there are two examples at the bottom of the post. The first example shows how to use it for making directories and moving files, the second showws an example of working with uploaded files.
It does seem to be more of a permissions thing, and FTP may be an easier solution.