Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello every one,below is the code which i wrote to upload the files to the folder and get back from it.I created a folder called upload which can store the uploaded files.After i upload the files i get the msg successfully uploaded but it wont get stored in the upload folder to get back the file.Plese let me know what is wrong in the code and how can i store it in the upload folder or any other folder.Code: Select all
<?php
$uploaddir= "upload/";
// Where you want the files to upload to
//Important: Make sure this folders permissions is 0777!
$allowed_ext= "jpg, gif, png, pdf, html, doc";
// These are the allowed extensions of the files that are uploaded
$max_size= "750000";
// 750000 is the same as 7500kb
$max_height= "10000";
// This is in pixels - Leave this field empty if you don't want to upload images
$max_width= "10000";
// This is in pixels - Leave this field empty if you don't want to upload images
// Check Extension
$extension= pathinfo($_FILES['file']['name']);
$extension= $extension[extension];
$allowed_paths= explode(", ",$allowed_ext);
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_paths[$i] == "$extension") {
$ok="1";
}
}
// Check File Size
if ($ok=="1") {
if($_FILES['file']['size'] > $max_size)
{
print "File size is too big!";
exit;
}
// Check Height & Width
if ($max_width && $max_height) {
list($width, $height, $type, $w) = getimagesize($_FILES['file']['tmp_name']);
if($width > $max_width || $height > $max_height)
{
print "File height and/or width are too big!";
exit;
}
}
// The Upload Part
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'. $_FILES['file']['name']);
}
print "Your file has been uploaded successfully! Yay!";
} else {
print "Incorrect file extension!";
}
?>
<form action="upload.php" method="post" ENCTYPE="multipart/form-data">
File: <input type="file" name="file" size="30"> <input type="submit" value="Upload!">
</form>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]