-
מצאתי מודול העלאה מאובטח בגיטהוב בפרויקט הזה
וזה הקוד:אלא מה, שכשאני מפעיל אותו הוא מתלונן על בעיה בשורה 60
Fatal error: Uncaught Error: Call to undefined function generateSessionToken() in C:\xampp\htdocs\tool\העלאת קבצים\A\tool\uploader4.php:60 Stack trace: #0 {main} thrown in C:\xampp\htdocs\tool\העלאת קבצים\A\tool\uploader4.php on line 60<?php if( isset( $_POST[ 'Upload' ] ) ) { // Check Anti-CSRF token checkToken( $_REQUEST[ 'user_token' ], $_SESSION[ 'session_token' ], 'index.php' ); // File information $uploaded_name = $_FILES[ 'uploaded' ][ 'name' ]; $uploaded_ext = substr( $uploaded_name, strrpos( $uploaded_name, '.' ) + 1); $uploaded_size = $_FILES[ 'uploaded' ][ 'size' ]; $uploaded_type = $_FILES[ 'uploaded' ][ 'type' ]; $uploaded_tmp = $_FILES[ 'uploaded' ][ 'tmp_name' ]; // Where are we going to be writing to? $target_path = DVWA_WEB_PAGE_TO_ROOT . 'hackable/uploads/'; //$target_file = basename( $uploaded_name, '.' . $uploaded_ext ) . '-'; $target_file = md5( uniqid() . $uploaded_name ) . '.' . $uploaded_ext; $temp_file = ( ( ini_get( 'upload_tmp_dir' ) == '' ) ? ( sys_get_temp_dir() ) : ( ini_get( 'upload_tmp_dir' ) ) ); $temp_file .= DIRECTORY_SEPARATOR . md5( uniqid() . $uploaded_name ) . '.' . $uploaded_ext; // Is it an image? if( ( strtolower( $uploaded_ext ) == 'jpg' || strtolower( $uploaded_ext ) == 'jpeg' || strtolower( $uploaded_ext ) == 'png' ) && ( $uploaded_size < 100000 ) && ( $uploaded_type == 'image/jpeg' || $uploaded_type == 'image/png' ) && getimagesize( $uploaded_tmp ) ) { // Strip any metadata, by re-encoding image (Note, using php-Imagick is recommended over php-GD) if( $uploaded_type == 'image/jpeg' ) { $img = imagecreatefromjpeg( $uploaded_tmp ); imagejpeg( $img, $temp_file, 100); } else { $img = imagecreatefrompng( $uploaded_tmp ); imagepng( $img, $temp_file, 9); } imagedestroy( $img ); // Can we move the file to the web root from the temp folder? if( rename( $temp_file, ( getcwd() . DIRECTORY_SEPARATOR . $target_path . $target_file ) ) ) { // Yes! $html .= "<pre><a href='${target_path}${target_file}'>${target_file}</a> succesfully uploaded!</pre>"; } else { // No $html .= '<pre>Your image was not uploaded.</pre>'; } // Delete any temp files if( file_exists( $temp_file ) ) unlink( $temp_file ); } else { // Invalid file $html .= '<pre>Your image was not uploaded. We can only accept JPEG or PNG images.</pre>'; } } // Generate Anti-CSRF token generateSessionToken(); ?> -
והשאלה השניה היא, איפה במודול העלאה הזה, אני מגדיר את גודל הקובץ המירבי?
<?php $dir = 'C:/xampp/htdocs/tool/העלאת קבצים/upload/'; $url = 'http://XXXX.XXX/tool/העלאת קבצים/upload/'; if($_FILES['myfile']['error'] != 0) { echo "שגיאה בשליחת הקובץ לשרת, קוד שגיאה: {$_FILES['myfile']['error']}"; } else { if(move_uploaded_file($_FILES['myfile']['tmp_name'], $dir . $_FILES['myfile']['name'])) { echo "הקובץ הועלה בהצלחה!! <br /> :קישור לקובץ <a href='{$url}{$_FILES['myfile']['name']}'>{$url}{$_FILES['myfile']['name']}<a/>"; } else { echo 'שגיאה בהעברת הקובץ מתקיית הקבצים הזמניים בשרת למיקום הסופי.'; } } ?>
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות