Click here to Skip to main content
15,892,480 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to convert string into code? Pin
SimpleData29-Apr-09 6:56
SimpleData29-Apr-09 6:56 
GeneralRe: how to convert string into code? Pin
rachelicohen29-Apr-09 7:02
rachelicohen29-Apr-09 7:02 
GeneralRe: how to convert string into code? Pin
SimpleData29-Apr-09 7:16
SimpleData29-Apr-09 7:16 
JokeRe: how to convert string into code? Pin
Rolando CC29-Apr-09 7:22
professionalRolando CC29-Apr-09 7:22 
QuestionMessage Removed Pin
29-Apr-09 5:39
professionalN_tro_P29-Apr-09 5:39 
AnswerRe: How to force Settings.Settings to update Pin
Henry Minute29-Apr-09 8:33
Henry Minute29-Apr-09 8:33 
QuestionDatagridview refreshing problems Pin
surfswirl29-Apr-09 5:33
surfswirl29-Apr-09 5:33 
QuestionWebClient.UploadFile won't upload the file. Pin
Member 441789229-Apr-09 4:06
Member 441789229-Apr-09 4:06 
Hello.
Im having a php post site on my server where i can upload files.
The problem is just that it doest upload the file at all.
Im trying through the php script to upload a file to the database. It works fine when i do it manually from the site, but not when im using UploadFile().

My C# code looks like:
string file = "1.jpg";
string url = "http://myserver.net/ind.php?userid="+_userid+"";

try
{
WebClient InsertClient = new WebClient();
byte[] Response = InsertClient.UploadFile(url, "POST", file);
label1.Text = Response.Length.ToString();


}
catch (Exception ex)
{
label1.Text = ex.ToString();
}

And the uploadsite looks like and is called "ind.php":

$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}

include "dbcon.php";

$query = "INSERT INTO files (userid, imageData ) ".
"VALUES ('".$_GET['userid']."', '$content')";

mysql_query($query) or die('Error, query failed');

echo "
File $fileName uploaded
";


It only adds the userid to the database but without any content of the file.
Have anyone got this problem before?


AnswerRe: WebClient.UploadFile won't upload the file. Pin
Member 441789229-Apr-09 4:13
Member 441789229-Apr-09 4:13 
AnswerRe: WebClient.UploadFile won't upload the file. Pin
Member 441789229-Apr-09 4:19
Member 441789229-Apr-09 4:19 
AnswerRe: WebClient.UploadFile won't upload the file. Pin
jo H20-Jul-09 3:33
jo H20-Jul-09 3:33 
QuestionSample C# code to take the screenshots the application opened in windows mobile Pin
ujjawal kumar29-Apr-09 3:15
ujjawal kumar29-Apr-09 3:15 
AnswerRe: Sample C# code to take the screenshots the application opened in windows mobile Pin
Xmen Real 29-Apr-09 8:21
professional Xmen Real 29-Apr-09 8:21 
AnswerRe: Sample C# code to take the screenshots the application opened in windows mobile Pin
Henry Minute29-Apr-09 8:36
Henry Minute29-Apr-09 8:36 
QuestionMS Access Problem Pin
Star0929-Apr-09 1:39
Star0929-Apr-09 1:39 
AnswerRe: MS Access Problem Pin
musefan29-Apr-09 2:15
musefan29-Apr-09 2:15 
AnswerRe: MS Access Problem Pin
Luc Pattyn29-Apr-09 2:20
sitebuilderLuc Pattyn29-Apr-09 2:20 
QuestionRe: MS Access Problem Pin
Star0929-Apr-09 2:22
Star0929-Apr-09 2:22 
AnswerRe: MS Access Problem Pin
musefan29-Apr-09 2:29
musefan29-Apr-09 2:29 
GeneralRe: MS Access Problem Pin
Star0929-Apr-09 2:31
Star0929-Apr-09 2:31 
AnswerRe: MS Access Problem Pin
Star0929-Apr-09 2:38
Star0929-Apr-09 2:38 
Questionpaint is slow Pin
shefa' isied29-Apr-09 1:16
shefa' isied29-Apr-09 1:16 
AnswerRe: paint is slow Pin
Rolando CC29-Apr-09 3:37
professionalRolando CC29-Apr-09 3:37 
AnswerRe: paint is slow Pin
Xmen Real 29-Apr-09 8:19
professional Xmen Real 29-Apr-09 8:19 
QuestionAccessing internal class in different assebly Pin
Mirko198029-Apr-09 1:14
Mirko198029-Apr-09 1:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.