Jump to content

file upload


diwakar

Recommended Posts

  • 1 month later...

:bash: we can upload file to server through move_uploaded_file function of php

 

 

<html>

<head>

 

<title>Untitled Document</title>

</head>

 

<body>

 

<!--

hi there!

you can upload the file to the server using move_uploaded_file() function...

 

consider u have the form like this:

 

-->

<div align="center" >

<h2>Welcome To Our Site</h2>

<p>Lets upload a file for testing purposes</p>

 

 

<form action="uploadFile.php" method="post" enctype="multipart/form-data" >

 

<input type="file" name="profileImage" /><br>

 

 

<input type="submit" value="Upload File" /><br>

 

 

</form>

 

</div>

<!--

 

when u'll click on the Upload File button then the script i.e uploadFile.php specified in action attribute of the above form will perform the task to move the uploaded file to the server...

 

here the code for uploadFile.php

 

$fileName = $_FILES['profileImage']['name']

 

which is original name of file.

 

$path="C:uploadFiles/images/".$fileName;

 

which is the path where i want to place the uploaded file.

 

move_uploaded_file($_FILES['profileImage']['tmp_name'],$path);

 

here $_FILES['profileImage']['tmp_name'] is the temperory file uploaded on the server.. we wana move it from the that location to our own specified directory/folder...

 

so the function move_uploaded_file() moves the file to the path specified

 

-->

 

 

 

</body>

</html>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...