Jump to content

darox

New Members
  • Posts

    3
  • Joined

  • Last visited

darox's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Such a helpfull forum this is.
  2. Sorry sounding lazy guys, I want to learn. I actually do want to learn php but i'm learning vb.net right now and i just want to add this to my website. I don't mind if people upload .exe viruses, i mean i know the consequences but that's not a problem. I also know that hackers can upload malicious php scripts. I actually asked a mate about this and he said that all i need to do is not let them execute the scripts by changing the permissions to 644. http://i.gyazo.com/cf449615daf5c290de2d28104a2de0d3.png Is there anything else i should be aware of? Thanks.
  3. Hi guys, so i have this file upload script. When i upload a file it gets stored in /uploads and keeps the same file name. So if i upload a file "test.exe" the file will be available at uploads/test.exe What i want is that it generates a new file name like: "9daln292os.exe" so upload/9daln292os.exe This is my code: <?php // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $_FILES['uploadedfile']['tmp_name']; ?> <?php $file_type = $_FILES['userfile']['type']; $file_name = $_FILES['userfile']['name']; $file_ext = strtolower(substr($file_name,strrpos($file_name,"."))); if (!in_array($file_type, $FILE_MIMES) && !in_array($file_ext, $FILE_EXTS) ) $message = "Sorry, $file_name($file_type) is not allowed to be uploaded."; else $message = do_upload_function_here($upload_path_here, $upload_ur_upload_url_herel); ?> <?php $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded. Here is the link to your file: <a href=uploads/". basename( $_FILES['uploadedfile']['name']). ">". basename( $_FILES['uploadedfile']['name'])."</a>"; } else{ echo "There was an error uploading the file, please try again!"; } ?> I don't know any basic php i really need someone to give me the code ready please. Thanks much appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.