Usage /upload , read the information in the script.
/*
How the script is currently configured it works like this (EXAMPLE):
-The user types '/upload test.exe' (test.exe is in the mirc dir)
-The script will submit the file to www.google.com/upload.php
-The php file will move the file 'test.exe' to the dir 'upload/'
-The file can be found at 'www.google.com/upload/test.exe'
-This is an example
-- CONTENT OF THE PHP FILE NAMED 'upload.php' (remember the mirc script must point to this file --
<?php
//Set uploaddir, remember that for that folder you must set read+write permission,
//look for the command CHMOD and set the permissions in the folder to '777'
$uploaddir = "upload/";
$file = $uploaddir . $_FILES['uploadfile']['name'];
move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)
?>
--------------------------------------------------------------------------------------------------
*/
alias upload {
;-- Set these variables --
%hostofphpfile = www.google.com
%locationofphpfile = /upload.php
;-------------------------
%dest = $$1-
if ((!$file(%dest)) || ($isdir(%dest))) return
.remove upload.tmp
echo -a Uploading file %dest $+ ....
sockopen upload %hostofphpfile 80
}
On *:sockopen:upload:{
var %b = $md5() | write -c upload.tmp $+(--,%b,$lf,$&
Content-Disposition: form-data; name="uploadfile";,$&
filename=",$nopath(%dest),",$lf,$lf)
.copy -a " $+ %dest $+ " upload.tmp
write upload.tmp -- $+ %b
var %write = sockwrite -tn upload
%write POST %locationofphpfile HTTP/1.1
%write Host: %hostofphpfile
%write Connection: close
%write Content-Type: multipart/form-data; boundary= $+ %b
%write Content-Length: $file(upload.tmp)
%write
.fopen upload upload.tmp
}
On *:sockwrite:upload:{
if $sock(upload).sq > 8192 || !$fopen(upload) { return }
if $fread(upload,8192,&a) {
sockwrite upload &a
}
else .fclose upload
}
On *:sockread:upload:{
var %temp
sockread %temp
if & 2* iswm %temp {
echo 3 -a SUCCESS!
}
elseif & 4* iswm & temp {
echo 4 -a FAILED!
}
}
On *:sockclose:upload:cleanupload
alias cleanupload {
.sockclose upload
if $fopen(upload) { .fclose upload }
unset %dest
.remove upload.tmp
}
i know this is old script but it almost fit my needs. great job on it...
o have a small problem when uploading a file when a file with the same name already exist...
what i want to do is overwrite the previous file always...
i am trying to upload a file called tv.csv and when i upload, it should overwrite that file...
is this posible...
man it seems like ages ago since I wrote this. The advantage of doing it like this is that it will always work if the webserver is up (I had problems doing it the FTP way, sometimes it would work, and sometimes the FTP server would mess up), and you can configure the php file to perform certain tasks on the file. On the other hand the ftp method of uploading is easier.