smphil
asked on
Uploading images
How come I keep getting no files specified ? how do I figure out the path. If thats the problem. This page is on my website where my sites hosted too.
<?php
if($file_name !="") {
copy ("$file", "/usr/local/root/$file_nam e")
or die("Could not Copy the File");
}
else {die("No Files Specified"); }
?>
<html><head><title>Upload Complete</title></head>
<body><h3>File upload succeeded...</h3>
<ul>
<li>Sent: <?php echo "$file_name"; ?>
<li>Size: <?php echo "$file_size"; ?>
<li>Type: <?php echo "$file_type"; ?>
</ul>
<a href="<?php echo "$file_name" ?> ">
Click Here to View File</a>
</body>
</html>
<?php
if($file_name !="") {
copy ("$file", "/usr/local/root/$file_nam
or die("Could not Copy the File");
}
else {die("No Files Specified"); }
?>
<html><head><title>Upload Complete</title></head>
<body><h3>File upload succeeded...</h3>
<ul>
<li>Sent: <?php echo "$file_name"; ?>
<li>Size: <?php echo "$file_size"; ?>
<li>Type: <?php echo "$file_type"; ?>
</ul>
<a href="<?php echo "$file_name" ?> ">
Click Here to View File</a>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cory
$file_name is the name of the actual uploaded file
Then try...
$file_name = $_FILES['file_name']['tmp_ name'];
if($file_name != "") {
copy ($file_name, "/usr/local/root/$file_nam e") or die("Could not Copy the File");
} else {
die("No Files Specified");
}
And do make sure that your form has the property enctype="multipart/form-da ta"
$file_name = $_FILES['file_name']['tmp_
if($file_name != "") {
copy ($file_name, "/usr/local/root/$file_nam
} else {
die("No Files Specified");
}
And do make sure that your form has the property enctype="multipart/form-da
also, here is an upload function you could try using :
function upload_file()
{
//file too big
if($_FILES['userfile']['si
return -1;
//file name
$userfile_t=$_FILES['userf
//upload dir
$dir="absolute/path/to/upl
$dest=$dir . $userfile;
//file correctly uploaded
if(is_uploaded_file($userf
{
//we move it to upload dir
if(!@move_uploaded_file($u
return -3;
//set perission
@chmod($dest, 0664);
}
else
return -3;
//all right!
return 1;
}
I think your problem is that your using $file as the filename.. ( i presume that this is what you call the input text box name on your form) and doing this is correct. you must reference the filename using $_REQUEST['file']['tmp_nam
Cheers,