php not uploading to folder. Any ideas?

Hi gurus,

I have been trying for the past couple of hours trying to get my php code to upload files to a specified folder.

So far, nothing is getting uploaded to that folder.

Here is my folder structure:

MainFolder
AdminFolder
UserFolder
Uploads folder
some code files

Inside both the AdminFolder and UserFolder are the files that upload files into the Uploads folder.

This is how I have been trying to upload the files:

public function SaveFolder($target = ‘/MainFolder/uploads/’)

Then during insert operation, I use the following to upload files to the Uploads Folder
->SaveFolder(’/MainFolder/uploadss/’)

Any idea why files are not getting uploaded there?
Thanks in advance

Try a var_dump(DIR); to see what directory you’re in.

I guess you are trying to save to /MainFolder/uploads/, where the first slash means the server root.

So if we imagine this is the folder structure on the server

etc/ home/ kaylech/ public_html/ MainFolder/ AdminFolder/ yourfile.php uploads/ // you want to save stuff here lib/ var/

but using “/MainFolder/uploads/” actually tells the server to try to store

etc/ home/ kaylech/ public_html/ MainFolder/ AdminFolder/ yourfile.php uploads/ lib/ MainFolder/uploads // <--- here var/

Which obviously won’t work

[hr]

in your savefolder method you could do something like

[php]$target = DIR . $target;[/php]

Which will prepend the directory you’re in. Just make sure you’re in the correct directory (you might have to go up a level or two), and make sure you don’t get any double directory separators (slashes) when concatenating different paths together.

Sponsor our Newsletter | Privacy Policy | Terms of Service