Core iTOps Tube

Wednesday, 16 May 2012

pass argument to html upload form

I am using an html form and a php upload script to upload files.



HTML form


Code:


<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">

<tr>

<form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">

<td>

<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">

<tr>

<td><strong>Single File Upload </strong></td>

</tr>

<tr>

<td>Select file

<input name="ufile" type="file" id="ufile" size="50" /></td>

</tr>

<tr>

<td align="center"><input type="submit" name="Submit" value="Upload" /></td>

</tr>

</table>

</td>

</form>

</tr>

</table>


PHP upload script:


PHP Code:







<?php
//set where you want to store files
//in this example we keep file in folder upload
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path"upload/".$HTTP_POST_FILES['ufile']['name'];
if(
$ufile !=none)
{
if(
copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo 
"Successful<BR/>";

//$HTTP_POST_FILES['ufile']['name'] = file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$HTTP_POST_FILES['ufile']['name']."<BR/>";
echo 
"File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
echo 
"File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";
echo 
"<img src=\"$path\" width=\"150\" height=\"150\">";
}
else
{
echo 
"Error";
}
}
?>







I can upload from browser fine and the uploaded files will be found in the folder upload in the web root.



I also can uplaod from localhost, give file path, for eg /usr/src/myimage.jpg in the "Select file" area and press "Upload" button from shell itself. The file gets uploaded fine to upload directory.


Code:


lynx http://localhost/upload.html

What I need is to pass the file path to html form as argument, so that I dont need to type the path after taking lynx. If there is any other method other than lynx, please help me on that also.



---------- Post updated at 10:47 PM ---------- Previous update was at 12:38 AM ----------



Anyone?




No comments:

Post a Comment