Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ IIS PHP
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 1: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
0 OriginalGriff 295
1 DamithSL 295
2 Sergey Alexandrovich Kryukov 207
3 Peter Leow 155
4 Afzaal Ahmad Zeeshan 154
0 OriginalGriff 7,460
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514

Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
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