Hey, working on a file upload script, and I have a basic one working fine. I just want to add a bit of security to it so that people I work with dont accidently upload useless files to our server. Here is what I have so far.
But it wont work. And I can't figure out why.
Edited out code due to repost below.
Problems with a file upload script
Moderator: General Moderators
Problems with a file upload script
Last edited by aredden on Tue May 29, 2007 11:07 am, edited 1 time in total.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Ok, so if i have this i get no error messages. but at the same time I dont think the move_upload_file is working out properly.
this is driving me mad, everything to me looks right remove the if and the ( ) around move_upload_file and get a "Parse error: parse error, unexpected '{' in /home/content/f/m/a/fmafadmin/html/Response/uploader.php on line 17" which i understand because { are for if contatining commands with an if statement. so at the moment im a bit stuck with this. :S
Code: Select all
<?php
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if($_FILES['uploadedfile']['type'] == "text/csv")
{
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded. ";
echo ('<a href="main.php" target="_parent">Click Here</a> to enter Fare Quote.');
}
else
{
echo "There was an error uploading the file, please try again!";
}
}
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Show your form please.
On second thought, try this for starters...
Then after you run it once to upload the file, view the source to see what the file type. I suspect that the conditional is for some reason evaluating to false so there is no upload.
On second thought, try this for starters...
Code: Select all
<?php
$target_path = "uploads/";
$target_path .= basename( $_FILES['uploadedfile']['name']); // Why are you doing this?
echo '<-- Upload File Type is ' . $_FILES['uploadedfile']['type'] . ' ... -->';
//if ($_FILES['uploadedfile']['type'] == "text/csv")
//{
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded. ";
echo ('<a href="main.php" target="_parent">Click Here</a> to enter Fare Quote.');
}
else
{
echo "There was an error uploading the file, please try again!";
}
//}
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I would take a look at Swiftmailer written by our very own d11wtq. It has support for mailing attachments. I am sure you could easily integrate the upload with the mailing.