Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cent040's avatar

I want to upload file form local path to server.

Hi, I want to upload file from local to Server in PHP i.e A page have text box i will give local file path on textbox. TextBox input like : D:/files/test.zip

0 likes
6 replies
Snapey's avatar

In your form, add a file input like;

<form action="upload" method="post" enctype="multipart/form-data">
  {{ csrf_field() }}
    Choose a file:
    <input type="file" name="uploadedfile" id="uploadedfile">
    <input type="submit" value="Upload Image" name="submit">
</form>

Create a route to accept the upload request

Follow the Laravel manual for uploading files

https://laravel.com/docs/5.3/requests#retrieving-uploaded-files

cent040's avatar

Hi, @Snapey. thanks for help. But I don't want input type="file".. I want type="text" i will give path. like D:/files/file.zip. I want this becuase i am writing APIs that will take file form folder and upload on server every day.

Snapey's avatar

Then no, you cannot do it. All transactions are initiated on the client. Its no use the server knowing where the file is coming from.

lasse's avatar

A shell script, SFTP and a cron job should fit the bill.

cent040's avatar

Yes Thanks @Snapey . It's exactly same error. File could not be opened. Server does now know about file.

@barbarouspony . Yes using sftp/scp it's working fine.

Thanks to both of you.

Please or to participate in this conversation.