File Uploads Can not be Opened

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
justravis
Forum Commoner
Posts: 53
Joined: Mon Dec 16, 2002 3:18 am
Location: San Diego, CA
Contact:

File Uploads Can not be Opened

Post by justravis »

Getting these errors:
Warning: Unable to open 'file1' for reading: No such file or directory in /home/clinical/public_html/admin/journal/article/art4/add_files.phps on line 18

Warning: Unable to open 'file2' for reading: No such file or directory in /home/clinical/public_html/admin/journal/article/art4/add_files.phps on line 18

Warning: Unable to open 'file3' for reading: No such file or directory in /home/clinical/public_html/admin/journal/article/art4/add_files.phps on line 18

Warning: Unable to open 'file4' for reading: No such file or directory in /home/clinical/public_html/admin/journal/article/art4/add_files.phps on line 18

Warning: Unable to open 'file5' for reading: No such file or directory in /home/clinical/public_html/admin/journal/article/art4/add_files.phps on line 18

Already fixed issue with upload_tmp_dir not being set.

Any other ideas?

Here is the code:

Code: Select all

<h3>Add Files:</h3>
<form method=post action=<?php echo $PHP_SELF . "?artid=$artid" ?> enctype='multipart/form-data'>
<b>*Filenames can only have alphanumeric symbols and underscores (_). No spaces.</b><br>

&#1111;php]
<?php

$file_fields_count=5;

#File Uploads
if(isset($_POST&#1111;upload]))
&#123;
        for($i=1; $i<=$file_fields_count; $i++)
        &#123;
                $file="file$i";

                if($file)
                &#123;
                        copy($file, "$curfilespath/$file_name");

                        if($i==1 && isset($_POST&#1111;pdf]))
                        &#123;
                                mysql_query("UPDATE article SET pdf=$file_name WHERE id=$artid");
                        &#125;
                &#125;
                else
                &#123;
                        unlink($file);
                &#125;
        &#125;
&#125;

#File Fields Output
for($i=1; $i<=$file_fields_count; $i++)
&#123;
        $fieldname= 'file' . $i;

        echo "\t<input type=file name=$fieldname size=50><br>\n";

        if($i==1)
        &#123;
                echo "\t<input type=checkbox name=pdf>PDF version of the article.<br>\n";
        &#125;
&#125;

?>&#1111;/php]
        <input type=submit name=upload value=Upload>
</form>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Post Reply