|
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?
|
|
|
|
|
And yes, the upload form is a POST method
|
|
|
|
|
And the output from the upload site is that "File name cannot be empty"..
|
|
|
|
|
Your problem is with your PHP code which is looking at the wrong variables. The upload method places the info into $_FILES['file'], not $_FILES['userfile'].
Better late than never I suppose.
|
|
|
|
|
Bitmap bmpScreenshot;
Graphics gfxScreenshot;
bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(0, 0, 0, 0, bmpScreenshot.Size);
bmpScreenshot.Save(@"\screenshot.bmp", ImageFormat.Bmp);
It works fine in windows.But it is showing no extension method like CopyFromScreen in windowsmobile.
Would u pls help me out to take screenshot in windowsmobile in C#?
|
|
|
|
|
A Screen Capture Tool for Windows Mobile 5[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
There is a Mobile Development forum. You might have done better posting this question there.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
OleDbConnection clsConnection;
clsConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\.one.mdb;");
clsConnection.Open();
WTest1.oneDataSet f_table = new WTest1.oneDataSet();
OleDbDataAdapter dAdapter = new OleDbDataAdapter("select * from first", clsConnection);
dAdapter.Fill(f_table, "first");
clsConnection.Close(); I've used this code in a previous application and it worked fine, however in this application, it's giving me this error about FROM syntax.
Can someone please tell me what's wrong??
Star
|
|
|
|
|
are you sure there is table called 'first' and also do you have 2 spaces between 'from' and 'first'. Im sure queries don't like double spaces
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Star09 wrote: Data Source=C:\\.one.mdb
do you need the first period?
|
|
|
|
|
I have removed the path because it was so long, but I do have it in my application, lol.
As for the double spaces, didn't notice them, thanks, but still even though I removed the double spaces, still same runtime error
|
|
|
|
|
Star09 wrote: As for the double spaces, didn't notice them, thanks, but still even though I removed the double spaces, still same runtime error
you should reply that message to me....
What is the error message you are getting?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
the message doesn't make sense, Syntax error in FROM clause.
|
|
|
|
|
Okay when I commented my other connections, it worked.
|
|
|
|
|
Hi,
In my application, i used a theme.
and when i carry one form over another form, this process is too slow.
how can i solve this problem?
|
|
|
|
|
|
yes it is...because windows do not use Graphic card acceleration. Either develope full screen app or do not use heavy images those hurts the performance.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Exploring some MS assembly using reflector I found something odd: a class declared internal in one assembly that was being used in a different one.
That does not make sense to me. As far as you know, there is some (legal) way to achieve that, or Microsoft is using some C# and/or IL "magic" to make that possible?
|
|
|
|
|
|
Wow, I'd never tought that something like that existed!
Tank you
|
|
|
|
|
Yeah! Like he said.
Yet another .NET feature I've not encountered before, good to know.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I am trying to use the rendered output of a video player in my C# code. The program (which is the VLC media player) is written in plain C and is wrapped in a DLL.
I should pass pointers to two callback functions (dolock and unlock ) as string arguments (argv ) to the player when it is instantiated through a DLL call. here is the function signatures in C:
void *dolock (void *struct)
void unlock(void * struct)
(the struct arguments are not used in my case).
they appear in my C# code as:
public static IntPtr dolock(IntPtr ctx)
public static void unlock(IntPtr ctx)
I use delegates and Marshal.GetFunctionPointerForDelegate to obtain the function pointers.
This works perfect and I can see in the debugger that the player successfully invokes my dolock function. But, an exception is raised after the function invocation, when the dolock function returns with a pointer to a buffer. I can not understand if it is because the player is not allowed to write in the memory which is allocated in my program or I am returning a wrong pointer. The error is a famous one:
The instruction at ... referenced memory at "0x000000". The memory could not be "written" .
I have tried different ways to allocate the memory buffer (which I should return its pointer in dolock), all failed with the same error.
* Allocating space in the unmanaged section of the program memory using AllocHGlobal.
* using stackalloc to allocate the buffer in stack (unmovable by GC).
* using Bitmap and BitmapData GDI+ classes and returning the bitmapdata.scan0 pointer after locking the bitmap.
Any idea what might be the cause?
|
|
|
|
|
Is ctx , actually a struct? It might be that vlc is attempting to write to the struct it was expecting. If you are passing IntPtr.Zero it will try to write to memory location 0x000000.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
No, as I said, dolock and unlock are callback functions and it is the vlc which is actually passing these arguments to my program.
|
|
|
|
|
The problem is fixed.
I should use [UnmanagedFunctionPointer(CallingConvention.Cdecl)] attribute before my dolock/unlock functions.
|
|
|
|