Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //if they DID upload a file...
- if($_FILES['photo']['name'])
- {
- if (($_FILES["photo"]["type"] == "image/gif")
- || ($_FILES["photo"]["type"] == "image/jpeg")
- || ($_FILES["photo"]["type"] == "image/png")
- || ($_FILES["photo"]["type"] == "image/pjpeg"))
- {
- //if no errors...
- if(!$_FILES['photo']['error'])
- {
- //now is the time to modify the future file name and validate the file
- $new_file_name = strtolower($_FILES['photo']['tmp_name']); //rename file
- if($_FILES['photo']['size'] > (512000)) //can't be larger than (512kb) / 1 MB 10240000
- {
- $valid_file = false;
- $ruta = '';
- $message = 'Oops! Your file\'s size is to large.';
- }else{
- $valid_file = true;
- }
- //if the file has passed the test
- if($valid_file == true)
- {
- //move it to where we want it to be
- //move_uploaded_file($_FILES['photo']['tmp_name'], $path.$_FILES['photo']['name']);
- $currentdir = getcwd();
- $target = $currentdir .'\\profiles\\' . basename($_FILES['photo']['name']);
- move_uploaded_file($_FILES['photo']['tmp_name'], $target);
- $message = 'Congratulations! Your file was accepted.';
- }
- }
- //if there is an error...
- else
- {
- //set that to be the returned message
- $message = 'Ooops! Your upload triggered the following error: '.$_FILES['photo']['error'];
- }
- }else{
- $message = 'Formato invalido';
- $ruta = '';
- }
- }
- echo $message."<br>";
- //you get the following information for each file:
- echo $_FILES['photo']['name']."<br>";
- echo $_FILES['photo']['size']."<br>";
- echo $_FILES['photo']['type']."<br>";
- echo $_FILES['photo']['tmp_name']."<br>";
Advertisement
Add Comment
Please, Sign In to add comment