How to find out which folder the user uploaded?

Asked

Viewed 197 times

1

I would like to know how to find out which folder the user uploaded to the form?

For example, if the user uploaded from the folder X, if the file was inside the X folder, I would like to run the following code:

$upload = copy($arqTemp, $pasta . $nomePDF);
$pastaExcluir = "C:/Users/Administrador/Desktop/X/";    
unlink($pastaExcluir . $arqName);

Or if he made one upload, out of the specific folder I simply use the move_uploaded_file():

$upload = move_uploaded_file($arqTemp, $pasta . $pdfName);

So, as i will find out by which folder was sent the file?

  • 2

    I’m not sure I understand your question. But when a user uploads a file, their data comes in the $_FILES variable. Files are immediately moved to the temporary folder of the server (usually /tmp on linux).

  • 4

    For the sake of privacy (and it better be so) browsers do not send the actual paths of the source files. If your application depends on it, it is the case to rethink the problem and create another solution.

  • @Bacco, I rethought (long time(lie, were minutes)) and abandoned this idea kkkkk.

1 answer

3


I understood that you want to delete the file after the user uploaded it. Right?

Assuming that yes, you you won’t be able to do this. When the user does upload, you get a copy of that file and do whatever you want with it, but you don’t have access to the client’s file system nor have any way of knowing that this file came from there.

If the application is running on the client’s own computer, you have access to the file system, but it remains without knowing where the file came from. Browser does not provide this information.

If this is really very important, maybe you can manage using some plugin, creating some browser extension or something, which goes beyond the scope of PHP.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.