Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

File Upload issues

Guest
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>
TOPICS
Server side applications

Views

244
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 17, 2008 Sep 17, 2008

Copy link to clipboard

Copied

LATEST
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/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines