Page 1 of 1

Uploading from batch

Posted: Fri Nov 02, 2007 6:43 pm
by phpFrk
Hello guys,

Im new here...

Neways im working on a script to upload file automatically on the server. The files i was to upload are created through a batch file on windows.
I already have a php page through which files can be uploaded and processes, but u have to give the location of the file yourself.

What i want to do is once the batch file has created the file, it trigger the same upload page(or similar created to work with this batch) and send the Location of the File that has been created so it can be uploaded on the server.

Is it possible to get upload this way?

I tried send the location of file through URL and used $_GET but didnt work :(



Ill be grateful for any help

Thank you

PHPFrk

Posted: Fri Nov 02, 2007 6:47 pm
by Christopher
Well, you can either have the batch file call the uploader or poll the directory where uploads go checking for files.

Posted: Fri Nov 02, 2007 9:00 pm
by phpFrk
Thanks for the reply abroint.

Actually the batch file would also be scheduled to run automatically, so most of the times thr wouldnt be any one to upload.



The upload page we have rite now, has a form like this:

Code: Select all

<form name="upload" enctype="multipart/form-data" action="doupload.php" method="post">
<input type=file name=file size=80>
<input type="submit" value="Upload it!">
</form>
once the Submit button is pressed goes on to doupload.php and processes(gets information and edits somethngs) the file and then upload it and add to database.


The form also has other Input boxes but they all can be sent by the batch file through URL and retrieved through $_GET on the doupload.php page.
The only problem is the file, how to tell it the it to process The file created by batch, basically we can send all other information sent by the upload page to the DoUpload Page through URL other thn file location as $_GET['file'] doesnt work.


The current doupload.php uses this to get the file:

Code: Select all

$file = $_FILES["file"];

So is there any way i can tell doupload.php to use the created file through URL?

Posted: Fri Nov 02, 2007 9:12 pm
by Christopher
You could use cURL to post the form if files are present.

Posted: Sat Nov 03, 2007 1:29 am
by phpFrk
thanks for the reply

Im using Wget.

in the batch i have this:

Code: Select all

wget --post-file C:\testfile.jpg http://localhost/doupload.php
in the doupload.php file i have this to test :

Code: Select all

<?

print_r($_FILES);

?>
^^Works with a normal html form upload

But no luck after running it, just get

Code: Select all

Array()

Posted: Sun Nov 04, 2007 5:21 am
by phpFrk
Ok just tried cURL as well.

Used this:

Code: Select all

curl -F "file=@testfile.txt"\ http://localhost/doupload.php
but get this error:

Code: Select all

curl: (26) failed creating formpost data
Tried without the "@", didnt give me an error but same thing as wget... print_r($_FILES) shows no information but:

Code: Select all

Array()