Jump to content

Upload file error.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
bleastan

bleastan

    Learning Programmer

  • Members
  • PipPipPip
  • 40 posts
Hey people i got a question where im seriously stuck with.

I got a php file which reads .csv files and writes it to the database. When i run it locally it works perfectly (with a standard xampp installation). However my problem is, when i put the exact same script on the webserver it cant find the file anymore (even tthough i point to it through the form)
Ik heb een php bestand die dus csv inleest en dit naar een database schrijft. Lokaal werkt dit helemaal 100% perfect (via xampp). Heres a small part of the code:
the form:
<?php
<table >
<form name="form" method="post" action=' . $_SERVER['PHP_SELF'] . '"">

<tr><td>Bestand: </td><td><input type="file" name="bestand"></td></tr>
<tr><td>knop</td><td><input type="submit" value="upload" name="eenValue"/></td></tr>
</table></form>';
?>

What it does is as soon as you submit the form it does php_self and the variable eenValue becomes upload. With this value it goes into the correct case where it does the following:


<?php
case 'upload':
if (!file_exists($_POST['bestand'])) {

echo "Bestand niet gevonden. \n";
//this means file not found.


} else {

insertFile();
}
break;
?>

what happens is is that i keep getting the 'file not found' error.. which is weird (in my opinion) cause locally Everything works but as soon as its on the webserver i get this.

So anyone have any suggestions? im seriously stuck here and have no clue whatsoever on how to fix it. Thanks in advance :)

edit: Is it possible that its the settings in php.ini somehow and ifso.. what needs to be changed? I havent made any changes to php.ini locally so mayb the host has done something?

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
the form needs to be typed as multipart, like this:

<form action="file.php" method="post" enctype="multipart/form-data">

__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
bleastan

bleastan

    Learning Programmer

  • Members
  • PipPipPip
  • 40 posts
Thanks alot problem solved (also used the $_File global, didnt know that one existed :P)