Indigo Rose Software

Go Back   Indigo Rose Software Forums > Old Versions > TrueUpdate 2.0

 
 
Thread Tools Display Modes
  #1  
Old 04-13-2005
Ninj Ninj is offline
Forum Member
 
Join Date: Jul 2004
Posts: 13
File Upload through HTTP.Submit Action

I've been trying to use the HTTP.Submit action to upload a file into a Web Server. There were some issues with the HTTP.Submit action before, and it has been resolved as per the release of latest version.

Now my problem is, I can't still use this action to upload the file into the Web Server. Is this really possible with this action or not? I've tried using an HTTP activeX before which achieve the desired result. The activeX was also using HTTP Protocol so I am assuming that this should also be possible with HTTP.Submit.

If it is not possible, this will be a great enhancement for the HTTP.Submit Action.

Thanks,
Ninj
  #2  
Old 04-13-2005
Mark's Avatar
Mark Mark is offline
Indigo Rose Staff Member
 
Join Date: Jun 2000
Location: Indigo Rose Software
Posts: 1,773
Hi Ninj,

Perhaps you could post your current action so that everyone here can have a look at it and perhaps make some suggestions?

What size file are you uploading? How is your Web script performing the upload? Is any part of the file being uploaded to your server? Is there an error code being returned by the HTTP.Submit() action? If so what is the error? What does HTTP.GetHTTPErrorInfo() return?

I believe that you said in the past that you have gotten this to work by increasing the timeout time to a very large number, does this still hold true?

Truthfully I do not see why the HTTP.Submit() action would not work in this scenario since, the action is simply passing the data to the web script, which then has to perform the actual upload task. Can you get this action to work on an empty text file?
__________________
MSI Factory The Next Generation Intelligent Setup Builder
  #3  
Old 04-13-2005
Ninj Ninj is offline
Forum Member
 
Join Date: Jul 2004
Posts: 13
Below is my script:

myValues = { filesfolder="/tu", OpCode=2, filesize=_FileSize, logfile="LogFile.txt", nameoffile="test.txt"};
SubmitFName = HTTP.Submit("http://www.mywebserver.com/cgi-bin/uploadtest.cgi", myValues, SUBMITWEB_POST, 200, 80, nil, nil);

Attached is a copy of the uploadtest.cgi, in order to attach it here I renamed as .txt.

As you have said, I thought that I have made it work before. However, I just noticed that the uploaded file is an empty file with 0 bytes. Therefore, the data was not really sent to the cgi, just the filename it seems.

Actually, I am already using the attached cgi for another application and am trying to make the upload work in TU2 as well without having to create another cgi script. Using a 3rd party HTTP activeX, the cgi script attached is able to upload a file to the server.
Attached Files
File Type: txt uploadtest.txt (2.1 KB, 37 views)
  #4  
Old 04-14-2005
Mark's Avatar
Mark Mark is offline
Indigo Rose Staff Member
 
Join Date: Jun 2000
Location: Indigo Rose Software
Posts: 1,773
Hi Ninj,

I tried to test this on my side but I kept getting error 2516 ("An internal server error has occurred." HTTP error code 500) when trying to test your script. This is probably because I do not have something needed installed on my server or something like that, but just to make sure do you receive any errors when you test your script?

Try inserting an Application.GetLastError() after the HTTP.Submit() action and test what the results are.
__________________
MSI Factory The Next Generation Intelligent Setup Builder
  #5  
Old 04-14-2005
Desmond's Avatar
Desmond Desmond is offline
Indigo Rose Staff Member
 
Join Date: Jul 2003
Posts: 628
Hello Ninj,

From what i can determine with yoru action, you're not actually passing the script any data to write into the file. A web script can't come onto your system and grab a file without permission. If you use that script through IE, IE has permission to access files on your system that you let it, and send them off to the script. Or at least that's how I understand it.

But with TrueUpdate, the script can access only what values you send to it from your lua script. Thoguh i'm not positive, how I would envision a file upload working is as follows:

1. UUencode the file in trueupdate (i'm not entirely sure how to do this)
2. send the following values to your script:
filename - the file, in form filename.ext
filedata - the actual data, the uuencoded string
3. Create a script that accepts those two values, uudecodes the string, and writes the filestream to the specified filename on the server. I haven't tried this, but in php i'd do somethign like this (please keep in mind this hasn't been tried or tested, but is where i'd start):

Code:
//save the below code into, say, upload.php and access it from trueupdate, method = post

<?php
//NEED POST VARIABLES:
//filedata: uuencoded string of file contents
//filename: string in form filename.ext

$filedata = convert_uudecode($_POST['filedata']);

if (!($writefilestream = fopen($_POST['filename'], 'w')))
   return;

fprintf($writefilestream, "%s", $filedata);

?>
All I did was googled uudecode and php, then writing to a file, and found those functions. Does it work? WHo knows! But this shoudl give you a place to start.

Lemme know how this works out for you. I've never done this, so it's kinda interesting!
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before.

WebHelp Guides: AMS | MSIFACT | SUF | TU | VP
  #6  
Old 04-14-2005
Intrigued's Avatar
Intrigued Intrigued is offline
Indigo Rose Customer
 
Join Date: Dec 2003
Location: Location! Location!
Posts: 6,058
Quote:
Originally Posted by Desmond
Hello Ninj,

From what i can determine with yoru action, you're not actually passing the script any data to write into the file. A web script can't come onto your system and grab a file without permission. If you use that script through IE, IE has permission to access files on your system that you let it, and send them off to the script. Or at least that's how I understand it.

But with TrueUpdate, the script can access only what values you send to it from your lua script. Thoguh i'm not positive, how I would envision a file upload working is as follows:

1. UUencode the file in trueupdate (i'm not entirely sure how to do this)
2. send the following values to your script:
filename - the file, in form filename.ext
filedata - the actual data, the uuencoded string
3. Create a script that accepts those two values, uudecodes the string, and writes the filestream to the specified filename on the server. I haven't tried this, but in php i'd do somethign like this (please keep in mind this hasn't been tried or tested, but is where i'd start):

Code:
//save the below code into, say, upload.php and access it from trueupdate, method = post

<?php
//NEED POST VARIABLES:
//filedata: uuencoded string of file contents
//filename: string in form filename.ext

$filedata = convert_uudecode($_POST['filedata']);

if (!($writefilestream = fopen($_POST['filename'], 'w')))
   return;

fprintf($writefilestream, "%s", $filedata);

?>
All I did was googled uudecode and php, then writing to a file, and found those functions. Does it work? WHo knows! But this shoudl give you a place to start.

Lemme know how this works out for you. I've never done this, so it's kinda interesting!
I would recommend also if you use that PHP code to "lock" the file. (flock)
__________________
Intrigued
www.amsuser.com
  #7  
Old 04-14-2005
Desmond's Avatar
Desmond Desmond is offline
Indigo Rose Staff Member
 
Join Date: Jul 2003
Posts: 628
oooh, that's a good point. to prevent possible errors cause of two attempts to write, right?

Is the code above correct? I'm oober new to PHP, i wasn't sure.
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before.

WebHelp Guides: AMS | MSIFACT | SUF | TU | VP
  #8  
Old 04-14-2005
Intrigued's Avatar
Intrigued Intrigued is offline
Indigo Rose Customer
 
Join Date: Dec 2003
Location: Location! Location!
Posts: 6,058
Here is an example of using the flock function from php.net (and a link to the page):

http://us2.php.net/flock

PHP Code:
<?php

$fp 
fopen("/tmp/lock.txt""w+");

if (
flock($fpLOCK_EX)) { // do an exclusive lock
   
fwrite($fp"Write something here\n");
   
flock($fpLOCK_UN); // release the lock
} else {
   echo 
"Couldn't lock the file !";
}

fclose($fp);

?>
__________________
Intrigued
www.amsuser.com
  #9  
Old 04-14-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
FWIW if a script is hitting a single file with simultaneous writes, it's a planning issue. PHP flock wouldn't cure that because you would still be "losing" writes, i.e. if a script's author is seeking to write two pieces of data at the same time then presumably they also wish to also read them... So in that case you would just use unique temp files in a FIFO cycle.

Note from php.net:

Quote:
flock() will not work on NFS and many other networked file systems. Check your operating system documentation for more details.

On some operating systems flock() is implemented at the process level. When using a multithreaded server API like ISAPI you may not be able to rely on flock() to protect files against other PHP scripts running in parallel threads of the same server instance!

flock() is not supported on antiquated filesystems like FAT and its derivates and will therefore always return FALSE under this environments (this is especially true for Windows 98 users).
  #10  
Old 04-14-2005
Intrigued's Avatar
Intrigued Intrigued is offline
Indigo Rose Customer
 
Join Date: Dec 2003
Location: Location! Location!
Posts: 6,058
I just wanted to put forth a point with regards to using fopen, as the original poster is. Whether that was the right choice... that's up for discussion and you Corey have more PHP experience than I and have found some good counter points to using fopen.

__________________
Intrigued
www.amsuser.com
  #11  
Old 04-14-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
Yes I'm glad you did. This also applies to all scripting, not just PHP. In general writing twice to one file such that it would cause an error is something to plan for beforehand in all scripts/programs which write files. Common methods include using temp files or using a "flag file" to detect when another file is "ready for writing" and a corresponding file queue, etc...
  #12  
Old 10-14-2005
mcme mcme is offline
Forum Member
 
Join Date: Oct 2005
Posts: 7
upload text file

I started same one in nes thread.

Last edited by mcme; 10-14-2005 at 04:07 PM. Reason: started in new thread
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 BUGS...Internet Download action and File Search Action Martin_SBT AutoPlay Media Studio 4.0 3 07-08-2003 09:30 AM
HOWTO: "Hide" Externally Referenced Files Support AutoPlay Media Studio 4.0 Examples 0 10-23-2002 04:19 PM
INFO: Tips for Debugging Action Lists in AutoPlay Media Studio 4.0 Support AutoPlay Media Studio 4.0 Examples 0 10-03-2002 09:38 AM
SUF6.0.0.2 -- installer hangs. jassing Setup Factory 6.0 4 12-20-2001 12:28 AM
Install only into one of several directories with specific existing file? RichardShaw Setup Factory 5.0 0 08-17-2000 03:29 PM


All times are GMT -6. The time now is 07:38 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software