Page 1 of 1

upload files clicking on a link

Posted: Wed Oct 05, 2005 5:11 am
by LetoAtreides
Hello,
maybe a simple thing but i haven't found anything about this issue.

I have a script that upload file pushing buttons, but i want substitute buttons with links.

could you help me to solve this problem?

Thank you,
LetoDuke


this is code with button:

Code: Select all

<?php
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$upload_dir = "inputfiles/";    				// Check if this one exist
$upload_url = "http://localhost/inputfiles/";
$message ="";

if ($_FILES['userfile']) {
     $message = do_upload($upload_dir, $upload_url);
}
else {
     $message = "Invalid File Specified. Ignore if you havent clicked upload yet";
}

print $message;

//	Function that perform the upload
function do_upload($upload_dir, $upload_url) 
{
    $temp_name = $_FILES['userfile']['tmp_name'];
    $file_name = "temp.txt";
    $file_type = $_FILES['userfile']['type']; 
    $file_size = $_FILES['userfile']['size']; 
    $result    = $_FILES['userfile']['error'];
    $file_url  = $upload_url.$file_name;
    $file_path = $upload_dir.$file_name;

	if ( $file_name =="") 								//File Name Check
	{	$message = "Invalid File Name Specified";
        return $message;
    }
    else if ( $file_size > 15000000) 					//File Size Check
	{  	$message = "The file size is over 15.000K.";
	   	return $message;
 	}    
    $result = move_uploaded_file($temp_name, $file_path);
    $message= ($result)?"" :"File not uploaded... some problem occurs.";
    
    return $message;
}
?>

Code: Select all

<title>Raw data upload</title>
<form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
	<input type="file" id="userfile" name="userfile"><input type="submit" name="upload" value="Upload">
</form>

Posted: Wed Oct 05, 2005 5:14 am
by Jenk
Please use [syntax=php]for posting php code,[/syntax][syntax=php]tags for other code or output.[/syntax]

Posted: Wed Oct 05, 2005 7:41 am
by feyd
I don't see any link doing the submission. :?