<? Php // Upload $ upsize here to determine the size of the uploaded file $ Uppath = "/attached/"; // File Upload path // Convert the root directory path If (strpos ($ uppath, "/") = 0) { $ I = 0; $ Thpath = $ _ SERVER ["SCRIPT_NAME"]; $ Thpath = substr ($ thpath, 1, strlen ($ thpath )); While (strripos ($ thpath ,"/")! = False) { $ Thpath = substr ($ thpath, strpos ($ thpath, "/") + 1, strlen ($ thpath )); $ I = ++ $ I; } $ Pp = ""; For ($ j = 0; $ j <$ I; ++ $ j) { $ Pp. = "../"; } $ Uppaths = $ pp. substr ($ uppath, 1, strlen ($ thpath )); } $ Filename = date ("y-m-d "); If (is_dir ($ uppaths. $ filename )! = TRUE) Mkdir ($ uppaths. $ filename, 0777 ); $ F = $ _ FILES ['pic ']; If ($ f ["type"]! = "Image/gif" & $ f ["type"]! = "Image/pjpeg" & $ f ["type"]! = "Image/jpeg" & $ f ["type"]! = "Image/x-png ") { Echo "<script> alert ('only files in image format upload'); window. close () </script> "; Return false; } // Obtain the file extension $ Temp_arr = explode (".", $ f ["name"]); $ File_ext = array_pop ($ temp_arr ); $ File_ext = trim ($ file_ext ); $ File_ext = strtolower ($ file_ext ); // New file name $ New_file_name = md5 (date ("YmdHis"). '.'. $ file_ext; Echo $ dest = $ uppaths. $ filename. "/". date ("ymdhis ")."_". $ New_file_name; // set the file name to the date plus the file name to avoid repeated upload directories. Echo $ dest1 = $ uppath. $ filename. "/". date ("ymdhis ")."_". $ New_file_name; // set the file name to the date plus the file name to avoid duplication. $ R = move_uploaded_file ($ f ['tmp _ name'], $ dest ); ?> |