Devv Active Member Licensed User Longtime User Mar 24, 2015 #1 Hello guys i'am trying to send a file to my server using php i tried the following Code: Copy <?php $FileName = $_GET['FileName']; if (!$FileName) $FileName = "FileName"; if (strstr($FileName,"php")) return; $PostData = file_get_contents("php://input"); $File = fopen($FileName,"wb"); fwrite($File, $PostData); fclose($File); echo "ACK"; ?> the following code is working but i'am always getting the file names as "FileName" WHY php is not recognizing the file name ?? can i send the file name with the file as an extra parameter ? PS: i'am using httputlis2 post file to send it to the php
Hello guys i'am trying to send a file to my server using php i tried the following Code: Copy <?php $FileName = $_GET['FileName']; if (!$FileName) $FileName = "FileName"; if (strstr($FileName,"php")) return; $PostData = file_get_contents("php://input"); $File = fopen($FileName,"wb"); fwrite($File, $PostData); fclose($File); echo "ACK"; ?> the following code is working but i'am always getting the file names as "FileName" WHY php is not recognizing the file name ?? can i send the file name with the file as an extra parameter ? PS: i'am using httputlis2 post file to send it to the php
DonManfred Expert Licensed User Longtime User Mar 24, 2015 #2 Devv said: WHY php is not recognizing the file name ?? Click to expand... Cause you dont give a filename with a postfile request. You need to use a multipartpost to give a file AND a (or even more) value with one postrequest. See my signature for a Example Upvote 0
Devv said: WHY php is not recognizing the file name ?? Click to expand... Cause you dont give a filename with a postfile request. You need to use a multipartpost to give a file AND a (or even more) value with one postrequest. See my signature for a Example
Devv Active Member Licensed User Longtime User Mar 24, 2015 #3 DonManfred said: Cause you dont give a filename with a postfile request. You need to use a multipartpost to give a file AND a (or even more) value with one postrequest. See my signature for a Example Click to expand... thanks for fast replay DonManfred the files i'am working with is less than 50 KB. sorry for this silly question but i'am a noob multipartpost: does mean sending the file part after part each part as one http post or it does mean that a single http post with more than one parameter ? anyway is their is a difference in the request time if using normal or multipart post ? Upvote 0
DonManfred said: Cause you dont give a filename with a postfile request. You need to use a multipartpost to give a file AND a (or even more) value with one postrequest. See my signature for a Example Click to expand... thanks for fast replay DonManfred the files i'am working with is less than 50 KB. sorry for this silly question but i'am a noob multipartpost: does mean sending the file part after part each part as one http post or it does mean that a single http post with more than one parameter ? anyway is their is a difference in the request time if using normal or multipart post ?
DonManfred Expert Licensed User Longtime User Mar 24, 2015 #4 See my example. I´m using two files in ONE uploadrequest. You can put more... You need to handle the files then via the $_FILES array like in an normal webpage-formular-request. Upvote 0
See my example. I´m using two files in ONE uploadrequest. You can put more... You need to handle the files then via the $_FILES array like in an normal webpage-formular-request.
DonManfred Expert Licensed User Longtime User Mar 24, 2015 #5 Devv said: anyway is their is a difference in the request time if using normal or multipart post ? Click to expand... not really... a few bytes more to send. And you need to handle the given vars in another way than you did in a postfile-request Upvote 0
Devv said: anyway is their is a difference in the request time if using normal or multipart post ? Click to expand... not really... a few bytes more to send. And you need to handle the given vars in another way than you did in a postfile-request
DonManfred Expert Licensed User Longtime User Mar 24, 2015 #6 Devv said: multipartpost: does mean sending the file part after part each part as one http post Click to expand... yes Upvote 0
Devv said: multipartpost: does mean sending the file part after part each part as one http post Click to expand... yes
Devv Active Member Licensed User Longtime User Mar 24, 2015 #7 Thanks bro , i'am seeing your script now so making a little change to my script is not possible to send a string (file name) with it ? i have to change the whole sender and receiver code right ? Upvote 0
Thanks bro , i'am seeing your script now so making a little change to my script is not possible to send a string (file name) with it ? i have to change the whole sender and receiver code right ?
DonManfred Expert Licensed User Longtime User Mar 24, 2015 #8 Devv said: so making a little change to my script is not possible to send a string (file name) with it ? Click to expand... No using postfile Devv said: i have to change the whole sender and receiver code right ? Click to expand... yes. You can store the filename in this code when sending... Code: Copy Dim fd As FileData fd.Initialize fd.Dir = File.DirAssets fd.FileName = "snap1.png" fd.KeyName = "Aufnahme" fd.ContentType = "application/octet-stream" files.Add(fd) Upvote 0
Devv said: so making a little change to my script is not possible to send a string (file name) with it ? Click to expand... No using postfile Devv said: i have to change the whole sender and receiver code right ? Click to expand... yes. You can store the filename in this code when sending... Code: Copy Dim fd As FileData fd.Initialize fd.Dir = File.DirAssets fd.FileName = "snap1.png" fd.KeyName = "Aufnahme" fd.ContentType = "application/octet-stream" files.Add(fd)