0
File Upload issues

/t5/dreamweaver-discussions/file-upload-issues/td-p/110775
Sep 17, 2008
Sep 17, 2008
Copy link to clipboard
Copied
There is a file upload that I have and I am getting an
error...
Notice: Undefined variable: file_list in C:\vhosts\mysite\upload\index.php on line 20
On line 20 in my php page happens to be the following code that is giving an error...$file_list .= "<option value=\"$file\" >$file</option>";
<?php
#for windows...
$dirname = $_SERVER['DOCUMENT_ROOT'].'/_assets/professor/';
//$dirname = "C:\\wamp\\www";
#(for Linux... $dirname = "user/local/apache/bin";)
$dir = opendir($dirname);
while(false != ($file = readdir($dir))){
if(($file != ".") and ($file != "..")){
$file_list .= "<option value=\"$file\" >$file</option>";
}
}
closedir($dir);
?>
This is what is in the body...
<form enctype="multipart/form-data" action="uploaded.php" method="POST">
<fieldset><legend>Upload Professor Image</legend>
<!-- MAX_FILE_SIZE must precede the file input field -->
<!--input type="hidden" name="MAX_FILE_SIZE" value="30000" /-->
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<div align="center"><input type="submit" value="Send File" /></div>
</fieldset>
</form>
<br>
<br>
<form action="delete.php" method="post">
<fieldset><legend>Delete Professor Image</legend>
<select name="deleteFile">
<?php echo($file_list); ?>
</select>
<div align="center"><input type="submit" name="go" value="Delete File"></div>
</fieldset>
Notice: Undefined variable: file_list in C:\vhosts\mysite\upload\index.php on line 20
On line 20 in my php page happens to be the following code that is giving an error...$file_list .= "<option value=\"$file\" >$file</option>";
<?php
#for windows...
$dirname = $_SERVER['DOCUMENT_ROOT'].'/_assets/professor/';
//$dirname = "C:\\wamp\\www";
#(for Linux... $dirname = "user/local/apache/bin";)
$dir = opendir($dirname);
while(false != ($file = readdir($dir))){
if(($file != ".") and ($file != "..")){
$file_list .= "<option value=\"$file\" >$file</option>";
}
}
closedir($dir);
?>
This is what is in the body...
<form enctype="multipart/form-data" action="uploaded.php" method="POST">
<fieldset><legend>Upload Professor Image</legend>
<!-- MAX_FILE_SIZE must precede the file input field -->
<!--input type="hidden" name="MAX_FILE_SIZE" value="30000" /-->
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<div align="center"><input type="submit" value="Send File" /></div>
</fieldset>
</form>
<br>
<br>
<form action="delete.php" method="post">
<fieldset><legend>Delete Professor Image</legend>
<select name="deleteFile">
<?php echo($file_list); ?>
</select>
<div align="center"><input type="submit" name="go" value="Delete File"></div>
</fieldset>
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/dreamweaver-discussions/file-upload-issues/m-p/110776#M192447
Sep 17, 2008
Sep 17, 2008
Copy link to clipboard
Copied
AdonaiEchad wrote:
> There is a file upload that I have and I am getting an error...
> Notice: Undefined variable: file_list in C:\vhosts\mysite\upload\index.php on
> line 20
> On line 20 in my php page happens to be the following code that is giving an
> error...$file_list .= "<option value=\"$file\" >$file</option>";
What that's telling you is that you're adding a value to a variable that
doesn't yet exist. In your case, it probably doesn't matter, but using
undefined variables is a potential security risk. To eliminate the
warning - and the risk - declare $file_list before using it:
$file_list = '';
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
> There is a file upload that I have and I am getting an error...
> Notice: Undefined variable: file_list in C:\vhosts\mysite\upload\index.php on
> line 20
> On line 20 in my php page happens to be the following code that is giving an
> error...$file_list .= "<option value=\"$file\" >$file</option>";
What that's telling you is that you're adding a value to a variable that
doesn't yet exist. In your case, it probably doesn't matter, but using
undefined variables is a potential security risk. To eliminate the
warning - and the risk - declare $file_list before using it:
$file_list = '';
--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

