Question

I want to create a symlink with PHP.

The symlink needs to go in the same place as the uploaded file, which should be fine right?

My real problem is that when using symlink(), I get a permission denied error on the same directory that PHP can write to from $_FILES.

I have done a test using text.txt as the test file, and link as the symlink:

symlink("repository/text.txt", "link");

The PHP script is run from content/folder/script.php. What am I doing wrong here? Do symlinks need file extensions (I doubt it) or something?

Was it helpful?

Solution

If this is the code you're using

symlink("repository/text.txt", "link");

And your script runs as /var/www/scripts/script.php the symlink will be created in the directory the script runs in.

Try using an absolute path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top