how i save uploded file??

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
pink
Forum Newbie
Posts: 3
Joined: Tue Dec 02, 2003 2:24 pm

how i save uploded file??

Post by pink »

hi every one :)
i think a have a selly proplam :oops:
i have a php code
to upload a file
when i uploded the file correctly how could i save it ?? :?:

thank you !
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

If you uploaded it successfully then you must have defined an upload directory for the file to go into. It should be in whatever folder you indicated in the script.

If you are not sure what I mean, please post the script so we can look at the code.
pink
Forum Newbie
Posts: 3
Joined: Tue Dec 02, 2003 2:24 pm

Post by pink »

hii again :)
unfourtinally i couldn't understsnd you very will :oops:

so this is my code :

Code: Select all

<?php
<?php
if ($_POST && $_FILES)
{
$wanted_type = "application/vnd.ms-excel";
$wanted_size = "51200";

$file_type = $_FILES["myfile"]["type"];
$file_size = $_FILES["myfile"]["size"];

if ($file_type != $wanted_type)
{
$i++;
print "<li>error, file type doesn't match</li>";
}
if ($file_size < $wanted_size)
{
$i++;
print "<li>error, file size is bigger then allowed</li>";
}
if (!$i || $i<=0)
{
print "go on";
}
}
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="myfile" size="40"><br>
<input type="submit" name="action" value="Upload!">
</form>


?>
so how could i indicat the directory :?: :!:
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Click: [google]php file upload tutorial[/google]
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Is this correct?

Code: Select all

<?php
if ($file_size < $wanted_size)
{
$i++;
print "<li>error, file size is bigger then allowed</li>";
} 
?>
Right now thats checking if the $file_size is less then the $wanted_size, it should be:

Code: Select all

<?php
if ($file_size > $wanted_size)
{
$i++;
print "<li>error, file size is bigger then allowed</li>";
} 
?>
Post Reply