Update: I have updated Chilkat. The latest version gives out more debug info, and its behaviour is different: It does not hang anymore at UploadInProgress. However, the problem still persists in the new version. I have therefore posted another question.
For completeness, here is the question anyways:
I have the following php file:
<?php
move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]);
?>
I am using it with Chilkat.Upload like this:
Dim _Chil As New Chilkat.Upload
_Chil.Ssl = True
_Chil.Hostname = "www.mydomain.com"
_Chil.Path = "/upload.php"
_Chil.AddFileReference("file", PathToFileThatShouldBeUploaded)
Dim bUploadStarted As Boolean = _Chil.BeginUpload()
If Not bUploadStarted Then
MessageBox.Show("Error starting the upload: " & NewLines(2) & _Chil.LastErrorText)
Return
End If
Do While _Chil.UploadInProgress 'Never becomes False, so the loop does not exit / break
_Chil.SleepMs(200)
Loop
Dim bSuccess As Boolean = _Chil.UploadSuccess
If Not bSuccess Then
MessageBox.Show("Error uploading: " & NewLines(2) & _Chil.LastErrorText)
Else
MessageBox.Show("Upload completed. :-)")
End If
It used to work, but then my hoster updated php, and now it no longer works.
Chilkat does not reveal any error.
I believe I have to get the error from the server. However, I don't know how.
This is how I would start:
<?php
if (move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]))
{
echo "Uploaded";
}
else
{
echo "File not uploaded. Err: ";
}
?>
2 questions:
How do I make it print out the error? I have read about
'.print_r($_FILES);
- How do I correctly include '.print_r($_FILES); in my php code?
- How could I receive / show this error while using Chilkat.Upload?
Thank you!
Edit:
This is my current code according to a comment:
https://example.com/upload.php?d:\test.avi
<?php
echo 'Error code: '.$_FILES['file']['error'];
move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]);
?>