Uploading of files |
[eluser]jbads[/eluser]
Im trying to create a function for a user to upload an avatar, and change it when they feel like it. This is within Code: function avatar_upload(){ As you can see, I would like to create the necessary folder for the user based on user ID. Obviously there is more code than this which handles upload etc, but this is throwing out this error Quote:A PHP Error was encountered Does anyone have any clues how to solve this or able to point me to a resource which could help? Cheers PS. I have echoed the Code: $user_id Code: $upload_path Code: base_url() I'm working on XAMPP on Windows.
[eluser]John_Betong[/eluser]
I made a quick search using Google and found a solution. Code: function avatar_upload(){
[eluser]jbads[/eluser]
Awesome mate, thanks heaps, at first this Googled code doesn't appear to do much more than mine, However, would I be right in thinking that the successful creation of the folder was based on putting the mkdir() function into a conditional statement?? As this would be a handy thing to have learned? I didn't put in C:// part.
[eluser]John_Betong[/eluser]
[quote author="jbads" date="1208255620"]Awesome mate, thanks heaps, at first this Googled code doesn't appear to do much more than mine, However, would I be right in thinking that the successful creation of the folder was based on putting the mkdir() function into a conditional statement?? As this would be a handy thing to have learned? I didn't put in C:// part.[/quote] Take a look at the online PHP Manual. I like it because it usually has quite a few cut & paste examples. The mkdir(...) function returns a TRUE/FALSE value. If the return value is not tested then can trip you out later. My old C++ teacher reckons this applies to every function's return value! edit: I think your problem was not using the leading double slash "//" - play about with it and see. edit: I also think mkdir(...) will be different when online Have fun...
[eluser]jbads[/eluser]
I spent ages looking at the manual. With no luck. The only thing I changed which made the code work was to put it into a conditional statement. Anyway, now Im working on putting that little test into a function of its own which I can use for folders containing different file types. Thanks, Jake
[eluser]Justin Patel[/eluser]
hi, if you can not create directory like that way you have mention ............. Try to get the absolute path not the relative ........ Use getcwd() - > this will return the absolute path ........ then you can populate the path for your need .... Best of luck , Justin |
Welcome Guest, Not a member yet? Register Sign In |