James Pybus - 2006-01-13

Logged In: YES
user_id=589188

I have had a quick look at this an discovered there was
already some code in vj_showticket.scp.php which only showed
the upload box for a specific user. I have fiddled a bit
from some code examples on php.net and have created a new
include called upload.inc.php and have included that where
the original code was and also modified upload.scp.php as
well to rename the file to "$date originalfilename". This
allows me to upload a file but doesn't add any info into the
ticket automatically so I have posted some info about the
file into the upload results page with a note asking the
user to paste it into the ticket themsevles.

I'm not a php programmer I just know enough to have a poke
around and copy code from other resources, so if any one
here can help me take this a bit further I would be glad.

-----------------------
includes/upload.inc.php
-----------------------
<br>
<table border=0 bgcolor="#EEEEEE">
<tr><td colspan=2>
<form enctype="multipart/form-data" action="<?echo
$g_base_url;?>/index.php?whattodo=upload" method="POST">
<center><b>Add Attachment (upload file)</b></center>
</td></tr>
<tr><td>
Filename:
</td><td>
<input name="userfile" type="file">
</td></tr>
<tr><td colspan=2>
<center><input type="submit" value="Upload"></center>
</td></tr>
</form>
</table>
-----------------------

-----------------------
script/upload.scp.php
-----------------------
<?php

$date = date('Y-m-j-H-i-s');

// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES
should be used instead
// of $_FILES.

$uploaddir = '/var/www/help/uploads/';
$uploadfile = $uploaddir . $date . ' ' .
basename($_FILES['userfile']['name']);
$newfilename = $date . ' ' .
basename($_FILES['userfile']['name']);

echo "<center>";
echo "<p>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'],
$uploadfile)) {
echo "File is valid, and was successfully uploaded.<br>";
echo "Please copy and paste all information below into
the detail section of the add job form:<br>";

$lines = array();

echo "<i>";
// echo "<br>Temp File Name: $userfile";
echo "<br>Original File Name: $userfile_name";
echo "<br>New File Name: <a
href=\"$g_base_url/uploads/$newfilename\"
target=\"new\">$newfilename</a>";
echo "<br>File Size: $userfile_size";
echo "<br>File Mime Type: $userfile_type<br>";
echo "Link To Uploaded File: <a
href=\"$g_base_url/uploads/$newfilename\"
target=\"new\">$g_base_url/uploads/$newfilename</a>";
$lines = file($upfile);

} else {
echo "There was an error uploading you file please click
the back button on your browser and try again.\n";
}

echo "</p>";
echo "</center>";

?>
-----------------------