0

I have application with cases ids structured with / in them, example: F-4/1, I am making upload script and making a folder for each case and it is failing on every /.

for F-4/1 it will make F-4 folder.

$prikaz8 ="F-4/1";

if (!file_exists('uploads/'.$prikaz8)) {
    mkdir('uploads/'.$prikaz8, 0777, true);
} 

I tried escaping it but didn't work. I can not find any information on this and how to solve it, please advise.

When I make them manually, I have it mounted over sshfs it lets me create it. I know I can replace / with something else, but I would like to keep case number the same. Would I even be able to target such folder with PHP later after creation?

enter image description here

4
  • Odd.. What cmd did you run over ssh mkdir -p F-4/1? File names cannot/should not contain '/', whats ls -la uploads/ show, I pretty sure it wont be / (looks like thunar is showing nested folder if only one folder, but thats odd too) Commented Jul 31, 2020 at 16:36
  • @LawrenceCherone I used OS X, not Linux to create it, i have disk mounted with sshfs, not ssh but I seen now on Linux it gets translated to :, but on OS X its shown like /. Yeah i can not do that... Commented Jul 31, 2020 at 16:40
  • if you store the filename in a db you can then call it what you like, store it with normalised filenames Commented Jul 31, 2020 at 16:47
  • @LawrenceCherone Yeah i will have to save info anyway. So I will just sanitize everything. The fact that OS X let me create it got my hopes up and confused me. I will have to adjust this based on servers, because this app will end up in-house on different servers. Thank you for your time. Commented Jul 31, 2020 at 16:51

1 Answer 1

2

Linux enviorment "/" used for seperators, hence we cant use it in file Or dir name. there is already answer for it. Kindly refer it this. click here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.