Click here to Skip to main content
13,146,402 members (48,092 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all!

How I can upload file to an HTTP Server (php script) with POST Method?

I need to upload some small text files simultaneously in C++. What will be the PHP script?

Please, help!
Posted 28-Dec-12 0:37am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If the HTML form was something like this:
<form enctype="multipart/form-data" action="script.php" method="POST">
  <input name="uploaded_file[]" type="file" />
  <input name="uploaded_file[]" type="file" />
  <input name="uploaded_file[]" type="file" />
  <input type="submit" value="Upload" />

Then the PHP script will be:
if(isset($_FILES['uploaded_file'])){ // check if any file was uploaded
for ($i = 0; $i < count ($_FILES['uploaded_file']); $i++) { // loop through files
if (move_uploaded_file ($_FILES['uploaded_file']['tmp_name'][$i], "target_directory/".$_FILES['uploaded_file']['name'][$i])) {
// upload succeeded 


Also make shure that php.ini upload_max_filesize and max_post_size values are set at appropiate values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100