simple php code for file hosting website is request (like rapidshare.com)?

  • Thread starter Thread starter ElricTheFullMetal
  • Start date Start date
E

ElricTheFullMetal

Guest
I wont do the coding for you, here is an example to restrict file type to image type only. property_image is name of file input tag, in ur case replace it with file.
<?php

if (($_FILES['property_image']['type'] == 'image/gif')
|| ($_FILES['property_image']['type'] == 'image/jpeg')
|| ($_FILES['property_image']['type'] == 'image/png')
|| ($_FILES['property_image']['type'] == 'image/pjpeg')
&& ($_FILES['property_image']['size'] / 1024 < 2000))
{
$img_path=time(). $_FILES['property_image']['name'];
$sql="insert into propertyimage(property_id,image_path) values('$maxproductid','$img_path')";
mysql_query($sql)or die("SELECT Error: ".mysql_error());

if(mysql_affected_rows()>0)
{
move_uploaded_file($_FILES["property_image"]["tmp_name"],"upload/" .time(). $_FILES["property_image"]["name"]);
}
}
?>
For Link to this file, just pick up the path for particular file u uploaded from path table and give its absolute link my concatenatin appropriate strings.
If u dont understand whats going on here, then u better read php tutorial here :
http://www.w3schools.com/PHP/php_file_upload.asp
Good Luck!
 
hi all ,
i want to create a file hosting website using php ,
1000s' of file hosting website already online , i want to create another one =)

i want it to be secure and don't want junk files to flood my server , can you please give me a simple upload.php code to handle the files (and give the users download link "not direct download link" ) thanks

the index.html looks like this

--------------------
<html>
<body>

<form action="upload.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html>
--------------------------------
 
Back
Top