login about faq

i want to upload a txt file to http server using chilkat c++.but i m getting the error HTTP/1.1 404 Not Found blocking upload

c++ code

#include <CkUpload.h>
#include <stdio.h>

void ChilkatSample(void)
    {
    CkUpload upload;

//  Specify the page (ASP, ASP.NET, Perl, Python, Ruby, CGI, etc)
    //  that will process the HTTP Upload.
    upload.put_Hostname("localhost/upload");
    upload.put_Path("/uploader.php");

//  Add one or more files to be uploaded.
    upload.AddFileReference("file1","d:\\hello.txt");

//  Do the upload.  The method returns when the upload
    //  is completed.
    //  This component also includes asynchronous upload capability,
    //  which is demonstrated in another example.
    bool success;
    success = upload.BlockingUpload();
    if (success != true) {
        printf("%s\n",upload.lastErrorText());
    }
    else {
        printf("Files uploaded!\n");
    }

}

int main()
{
    ChilkatSample();
}

html

<form enctype="multipart/form-data" method="post" action="uploader.php">
    Send this file: <input name="userfile" type="file" /><br />
    <input  type="submit" value="Send File" />
</form>

&lt;form enctype="multipart/form-data" method="post" action="uploader.php"&gt;
    Send this file: &lt;input name="userfile" type="file" /&gt;&lt;br /&gt;
    &lt;input  type="submit" value="Send File" /&gt;
&lt;/form&gt;

php

    <?php
        if (move_uploaded_file($_FILES['userfile']['tmp_name'], "uploads{$_FILES['userfile']['name']}")) {
            print "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}";
        } else {
            print "Upload failed!";
        }
    ?>

asked Apr 05 '15 at 02:37

dibyajyoti1994's gravatar image

dibyajyoti1994
1122

edited Apr 05 '15 at 19:30

jpbro's gravatar image

jpbro ♦
1.1k2618

Please post the contents of the LastErrorText property as they are immediately after the failing call.

(Apr 05 '15 at 19:31) jpbro ♦

@jpbro well after so many research now i am able to upload a file to asp.net server using above c++ chilkat program.when i m using php code to handle the uploaded file from the form.html the c++ program showing uploaded successfully but there is no file in the server .is there any problem in my php code? i m able to upload a file from browser to server using above php code but from the program its not ..

link

answered Apr 06 '15 at 03:25

dibyajyoti1994's gravatar image

dibyajyoti1994
1122

Unfortunately, I don't program with PHP, so I'm not very familiar with it and can't be of much help.

That said, when something appears successful (and the software on both ends of the connection are reporting success), but the file doesn't appear where you expect it to be, usually it has ended up somewhere unexpected (or under an unexpected filename in the expected location). Maybe if you output some more debugging info in your PHP code, it might indicate where it has actually gone? e.g.

<?php
        if (move_uploaded_file($_FILES['userfile']['tmp_name'], "uploads{$_FILES['userfile']['name']}")) {
            print "Received {$_FILES['userfile']['name']} - copied to {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}";
            print "Received {$_FILES['userfile']['name']} - or maybe copied to uploads{$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}";
        } else {
            print "Upload failed!";
        }
    ?>
link

answered Apr 06 '15 at 09:12

jpbro's gravatar image

jpbro ♦
1.1k2618

edited Apr 06 '15 at 09:15

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×65
×3

Asked: Apr 05 '15 at 02:37

Seen: 49,900 times

Last updated: Apr 06 '15 at 09:15

powered by OSQA