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!
Okay so I'm using some PHP to create an upload script and I got this following error:
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpLZUTH4' to 'http://www.sition.net/upload/resources5558.s2z' in /home2/zack/public_html/includes/do_upload.php on line 29
<?php
$target = "http://www.sition.net/upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if (!($uploaded_type=="s2z")) {
echo "You may only upload s2z or honmod files.<br>";
$ok=0;
}elseif (!($uploaded_type=="honmod")) {
echo "You may only upload s2z or honmod files.<br>";
$ok=0;
}
if ($ok==0) {
echo "Sorry your file was not uploaded";
}
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)){
echo "The file " . basename( $_FILES['uploadedfile']['name']). "has been uploaded";
}else{
echo "Sorry, there was a problem uploading your file.";
}
?>
Okay thanks I got it able to upload, however I'm trying to restrict what type of files can be uploaded. (I want just .s2z files and .honmod files to be able to be uploaded.) What should I use to restrict something like that because I tried this:
<?php
$target = "/*/*/public_html/upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if ($ok==0) {
echo "Sorry your file was not uploaded";
}else{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'],$target)){
echo "The file <b>".basename( $_FILES['uploaded']['name'])."</b> has been uploaded";
}else{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
This function will allow any file that is less than 3mb, has extension of jpeg,jpg,gif,tif,pdf,doc,xls or csv. also checks that the mime type of those files