上传文件,提示文件不存在的解决方法

在做公司的一个项目中,需要上传文件,使用的是AjaxUpload JS组件,选择完文件后,发送请求到指定接口,随即返回服务器上文件的相对路径,然后PHP再做其他工作(这不是重点)

处理上传的PHP程序,限制其文件大小为20M

php.ini中

post_max_size 20M

upload_max_filesize 20M

memory_limit 256M

ngint.conf中

client_max_body_size 518M

上传20M以下的文件,没有问题,但是,例如上传80M的文件,会报错,文件不存在,

if ( ! isset($_FILES[$field]))
{
  $this->set_error(‘upload_no_file_selected‘);
  return FALSE;
}

网上的解决方法是 设置 php.ini和nginx.conf中相应的属性,仍然报错,后来参考了鸟哥的一篇文章,才找到原因

解决方法:

php.ini中的post_max_size和upload_max_filesize 的值要大些,不能仅限于规定的值,比如这个20M,根据情况,这里设置200M,再次上传80M的文件,根据PHP程序本身的 $_FILES[‘file‘][‘error‘] 可得出 文件大小 超过限制 这样的提示

  1. SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
  2. {
  3. char *boundary, *s=NULL, *boundary_end = NULL, *start_arr=NULL, *array_index=NULL;
  4. char *temp_filename=NULL, *lbuf=NULL, *abuf=NULL;
  5. int boundary_len=0, total_bytes=0, cancel_upload=0, is_arr_upload=0, array_len=0;
  6. int max_file_size=0, skip_upload=0, anonindex=0, is_anonymous;
  7. zval *http_post_files=NULL; HashTable *uploaded_files=NULL;
  8. #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
  9. int str_len = 0, num_vars = 0, num_vars_max = 2*10, *len_list = NULL;
  10. char **val_list = NULL;
  11. #endif
  12. zend_bool magic_quotes_gpc;
  13. multipart_buffer *mbuff;
  14. zval *array_ptr = (zval *) arg;
  15. int fd=-1;
  16. zend_llist header;
  17. void *event_extra_data = NULL;
  18. int llen = 0;
  19. /**
  20. *检查是否超出最大上传文件大小,这是重点
  21. *从request_global中取出request_info结构体中的content_length元素,这个content_length应该是http 头信息中发给服务器的
  22. *如果content_length 大于php.ini中设置的post_max_size,就会由sapi_errror触发一个warning,这个warning不会被php接受(还有待研究)
  23. *通过nginx的log日志中也能发现此warning
  24. *
  25. */  
  26.  if (SG(request_info).content_length > SG(post_max_size)) {
  27.                 sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size));
  28.                 return;
  29.         }
  30. //取得上传文件的分隔符
  31. boundary = strstr(content_type_dup, "boundary");
  32. if (!boundary || !(boundary=strchr(boundary, ‘=‘))) {
  33. sapi_module.sapi_error(E_WARNING, "Missing boundary in multipart/form-data POST data");
  34. return;
  35. }
  36. boundary++;
  37. boundary_len = strlen(boundary);
  38. if (boundary[0] == ‘"‘) {
  39. boundary++;
  40. boundary_end = strchr(boundary, ‘"‘);
  41. if (!boundary_end) {
  42. sapi_module.sapi_error(E_WARNING, "Invalid boundary in multipart/form-data POST data");
  43. return;
  44. }
  45. } else {
  46. /* search for the end of the boundary */
  47. boundary_end = strchr(boundary, ‘,‘);
  48. }
  49. if (boundary_end) {
  50. boundary_end[0] = ‘‘;
  51. boundary_len = boundary_end-boundary;
  52. }
  53. /* Initialize the buffer */
  54. if (!(mbuff = multipart_buffer_new(boundary, boundary_len))) {
  55. sapi_module.sapi_error(E_WARNING, "Unable to initialize the input buffer");
  56. return;
  57. }
  58. //初始化$_FILE变量
  59. zend_hash_init(&PG(rfc1867_protected_variables), 5, NULL, NULL, 0);
  60. ALLOC_HASHTABLE(uploaded_files);
  61. zend_hash_init(uploaded_files, 5, NULL, (dtor_func_t) free_estring, 0);
  62. SG(rfc1867_uploaded_files) = uploaded_files;
  63. ALLOC_ZVAL(http_post_files);
  64. array_init(http_post_files);
  65. INIT_PZVAL(http_post_files);
  66. PG(http_globals)[TRACK_VARS_FILES] = http_post_files; //TRACK_VARS_FILE正是_FILE在php_core_globals.http_globals中的index (注1)
  67. #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
  68. if (php_mb_encoding_translation(TSRMLS_C)) {
  69. val_list = (char **)ecalloc(num_vars_max+2, sizeof(char *));
  70. len_list = (int *)ecalloc(num_vars_max+2, sizeof(int));
  71. }
  72. #endif
  73. zend_llist_init(&header, sizeof(mime_header_entry), (llist_dtor_func_t) php_free_hdr_entry, 0);
  74. if (php_rfc1867_callback != NULL) {
  75. multipart_event_start event_start;
  76. event_start.content_length = SG(request_info).content_length;
  77. if (php_rfc1867_callback(MULTIPART_EVENT_START, &event_start, &event_extra_data TSRMLS_CC) == FAILURE) {
  78. goto fileupload_done;
  79. }
  80. }
  81. while (!multipart_buffer_eof(mbuff TSRMLS_CC))
  82. {
  83. char buff[FILLUNIT];
  84. char *cd=NULL,*param=NULL,*filename=NULL, *tmp=NULL;
  85. size_t blen=0, wlen=0;
  86. off_t offset;
  87. zend_llist_clean(&header);
  88. if (!multipart_buffer_headers(mbuff, &header TSRMLS_CC)) {
  89. goto fileupload_done;
  90. }
  91. if ((cd = php_mime_get_hdr_value(header, "Content-Disposition"))) {
  92. char *pair=NULL;
  93. int end=0;
  94. while (isspace(*cd)) {
  95. ++cd;
  96. }
  97. while (*cd && (pair = php_ap_getword(&cd, ‘;‘)))
  98. {
  99. char *key=NULL, *word = pair;
  100. while (isspace(*cd)) {
  101. ++cd;
  102. }
  103. if (strchr(pair, ‘=‘)) {
  104. key = php_ap_getword(&pair, ‘=‘);
  105. if (!strcasecmp(key, "name")) {
  106. if (param) {
  107. efree(param);
  108. }
  109. param = php_ap_getword_conf(&pair TSRMLS_CC);
  110. } else if (!strcasecmp(key, "filename")) {
  111. if (filename) {
  112. efree(filename);
  113. }
  114. filename = php_ap_getword_conf(&pair TSRMLS_CC);
  115. }
  116. }
  117. if (key) {
  118. efree(key);
  119. }
  120. efree(word);
  121. }
  122. /* Normal form variable, safe to read all data into memory */
  123. if (!filename && param) {
  124. unsigned int value_len;
  125. char *value = multipart_buffer_read_body(mbuff, &value_len TSRMLS_CC);
  126. unsigned int new_val_len; /* Dummy variable */
  127. if (!value) {
  128. value = estrdup("");
  129. }
  130. if (sapi_module.input_filter(PARSE_POST, param, &value, value_len, &new_val_len TSRMLS_CC)) {
  131. if (php_rfc1867_callback != NULL) {
  132. multipart_event_formdata event_formdata;
  133. size_t newlength = 0;
  134. event_formdata.post_bytes_processed = SG(read_post_bytes);
  135. event_formdata.name = param;
  136. event_formdata.value = &value;
  137. event_formdata.length = new_val_len;
  138. event_formdata.newlength = &newlength;
  139. if (php_rfc1867_callback(MULTIPART_EVENT_FORMDATA, &event_formdata, &event_extra_data TSRMLS_CC) == FAILURE) {
  140. efree(param);
  141. efree(value);
  142. continue;
  143. }
  144. new_val_len = newlength;
  145. }
  146. #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
  147. if (php_mb_encoding_translation(TSRMLS_C)) {
  148. php_mb_gpc_stack_variable(param, value, &val_list, &len_list,
  149. &num_vars, &num_vars_max TSRMLS_CC);
  150. } else {
  151. safe_php_register_variable(param, value, new_val_len, array_ptr, 0 TSRMLS_CC);
  152. }
  153. #else
  154. safe_php_register_variable(param, value, new_val_len, array_ptr, 0 TSRMLS_CC);
  155. #endif
  156. } else if (php_rfc1867_callback != NULL) {
  157. multipart_event_formdata event_formdata;
  158. event_formdata.post_bytes_processed = SG(read_post_bytes);
  159. event_formdata.name = param;
  160. event_formdata.value = &value;
  161. event_formdata.length = value_len;
  162. event_formdata.newlength = NULL;
  163. php_rfc1867_callback(MULTIPART_EVENT_FORMDATA, &event_formdata, &event_extra_data TSRMLS_CC);
  164. }
  165. if (!strcasecmp(param, "MAX_FILE_SIZE")) {
  166. max_file_size = atol(value);
  167. }
  168. efree(param);
  169. efree(value);
  170. continue;
  171. }
  172. /* If file_uploads=off, skip the file part */
  173. if (!PG(file_uploads)) {
  174. skip_upload = 1;
  175. }
  176. /* Return with an error if the posted data is garbled */
  177. if (!param && !filename) {
  178. sapi_module.sapi_error(E_WARNING, "File Upload Mime headers garbled");
  179. goto fileupload_done;
  180. }
  181. if (!param) {
  182. is_anonymous = 1;
  183. param = emalloc(MAX_SIZE_ANONNAME);
  184. snprintf(param, MAX_SIZE_ANONNAME, "%u", anonindex++);
  185. } else {
  186. is_anonymous = 0;
  187. }
  188. /* New Rule: never repair potential malicious user input */
  189. if (!skip_upload) {
  190. char *tmp = param;
  191. long c = 0;
  192. while (*tmp) {
  193. if (*tmp == ‘[‘) {
  194. c++;
  195. } else if (*tmp == ‘]‘) {
  196. c--;
  197. if (tmp[1] && tmp[1] != ‘[‘) {
  198. skip_upload = 1;
  199. break;
  200. }
  201. }
  202. if (c < 0) {
  203. skip_upload = 1;
  204. break;
  205. }
  206. tmp++;
  207. }
  208. }
  209. total_bytes = cancel_upload = 0;
  210. if (!skip_upload) {
  211. /* Handle file */
  212. fd = php_open_temporary_fd_ex(PG(upload_tmp_dir), "php", &temp_filename, 1 TSRMLS_CC);
  213. if (fd==-1) {
  214. sapi_module.sapi_error(E_WARNING, "File upload error - unable to create a temporary file");
  215. cancel_upload = UPLOAD_ERROR_E;
  216. }
  217. }
  218. if (!skip_upload && php_rfc1867_callback != NULL) {
  219. multipart_event_file_start event_file_start;
  220. event_file_start.post_bytes_processed = SG(read_post_bytes);
  221. event_file_start.name = param;
  222. event_file_start.filename = &filename;
  223. if (php_rfc1867_callback(MULTIPART_EVENT_FILE_START, &event_file_start, &event_extra_data TSRMLS_CC) == FAILURE) {
  224. if (temp_filename) {
  225. if (cancel_upload != UPLOAD_ERROR_E) { /* file creation failed */
  226. close(fd);
  227. unlink(temp_filename);
  228. }
  229. efree(temp_filename);
  230. }
  231. temp_filename="";
  232. efree(param);
  233. efree(filename);
  234. continue;
  235. }
  236. }
  237. if (skip_upload) {
  238. efree(param);
  239. efree(filename);
  240. continue;
  241. }
  242. if(strlen(filename) == 0) {
  243. #if DEBUG_FILE_UPLOAD
  244. sapi_module.sapi_error(E_NOTICE, "No file uploaded");
  245. #endif
  246. cancel_upload = UPLOAD_ERROR_D;
  247. }
  248. offset = 0;
  249. end = 0;
  250. while (!cancel_upload && (blen = multipart_buffer_read(mbuff, buff, sizeof(buff), &end TSRMLS_CC)))
  251. {
  252. if (php_rfc1867_callback != NULL) {
  253. multipart_event_file_data event_file_data;
  254. event_file_data.post_bytes_processed = SG(read_post_bytes);
  255. event_file_data.offset = offset;
  256. event_file_data.data = buff;
  257. event_file_data.length = blen;
  258. event_file_data.newlength = &blen;
  259. if (php_rfc1867_callback(MULTIPART_EVENT_FILE_DATA, &event_file_data, &event_extra_data TSRMLS_CC) == FAILURE) {
  260. cancel_upload = UPLOAD_ERROR_X;
  261. continue;
  262. }
  263. }
  264. if (PG(upload_max_filesize) > 0 && total_bytes > PG(upload_max_filesize)) {
  265. #if DEBUG_FILE_UPLOAD
  266. sapi_module.sapi_error(E_NOTICE, "upload_max_filesize of %ld bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename);
  267. #endif
  268. cancel_upload = UPLOAD_ERROR_A;
  269. } else if (max_file_size && (total_bytes > max_file_size)) {
  270. #if DEBUG_FILE_UPLOAD
  271. sapi_module.sapi_error(E_NOTICE, "MAX_FILE_SIZE of %ld bytes exceeded - file [%s=%s] not saved", max_file_size, param, filename);
  272. #endif
  273. cancel_upload = UPLOAD_ERROR_B;
  274. } else if (blen > 0) {
  275. wlen = write(fd, buff, blen);
  276. if (wlen == -1) {
  277. /* write failed */
  278. #if DEBUG_FILE_UPLOAD
  279. sapi_module.sapi_error(E_NOTICE, "write() failed - %s", strerror(errno));
  280. #endif
  281. cancel_upload = UPLOAD_ERROR_F;
  282. } else if (wlen < blen) {
  283. #if DEBUG_FILE_UPLOAD
  284. sapi_module.sapi_error(E_NOTICE, "Only %d bytes were written, expected to write %d", wlen, blen);
  285. #endif
  286. cancel_upload = UPLOAD_ERROR_F;
  287. } else {
  288. total_bytes += wlen;
  289. }
  290. offset += wlen;
  291. }
  292. }
  293. if (fd!=-1) { /* may not be initialized if file could not be created */
  294. close(fd);
  295. }
  296. if (!cancel_upload && !end) {
  297. #if DEBUG_FILE_UPLOAD
  298. sapi_module.sapi_error(E_NOTICE, "Missing mime boundary at the end of the data for file %s", strlen(filename) > 0 ? filename : "");
  299. #endif
  300. cancel_upload = UPLOAD_ERROR_C;
  301. }
  302. #if DEBUG_FILE_UPLOAD
  303. if(strlen(filename) > 0 && total_bytes == 0 && !cancel_upload) {
  304. sapi_module.sapi_error(E_WARNING, "Uploaded file size 0 - file [%s=%s] not saved", param, filename);
  305. cancel_upload = 5;
  306. }
  307. #endif
  308. if (php_rfc1867_callback != NULL) {
  309. multipart_event_file_end event_file_end;
  310. event_file_end.post_bytes_processed = SG(read_post_bytes);
  311. event_file_end.temp_filename = temp_filename;
  312. event_file_end.cancel_upload = cancel_upload;
  313. if (php_rfc1867_callback(MULTIPART_EVENT_FILE_END, &event_file_end, &event_extra_data TSRMLS_CC) == FAILURE) {
  314. cancel_upload = UPLOAD_ERROR_X;
  315. }
  316. }
  317. if (cancel_upload) {
  318. if (temp_filename) {
  319. if (cancel_upload != UPLOAD_ERROR_E) { /* file creation failed */
  320. unlink(temp_filename);
  321. }
  322. efree(temp_filename);
  323. }
  324. temp_filename="";
  325. } else {
  326. zend_hash_add(SG(rfc1867_uploaded_files), temp_filename, strlen(temp_filename) + 1, &temp_filename, sizeof(char *), NULL);
  327. }
  328. /* is_arr_upload is true when name of file upload field
  329. * ends in [.*]
  330. * start_arr is set to point to 1st [
  331. */
  332. is_arr_upload = (start_arr = strchr(param,‘[‘)) && (param[strlen(param)-1] == ‘]‘);
  333. if (is_arr_upload) {
  334. array_len = strlen(start_arr);
  335. if (array_index) {
  336. efree(array_index);
  337. }
  338. array_index = estrndup(start_arr+1, array_len-2);
  339. }
  340. /* Add $foo_name */
  341. if (llen < strlen(param) + MAX_SIZE_OF_INDEX + 1) {
  342. llen = strlen(param);
  343. lbuf = (char *) safe_erealloc(lbuf, llen, 1, MAX_SIZE_OF_INDEX + 1);
  344. llen += MAX_SIZE_OF_INDEX + 1;
  345. }
  346. if (is_arr_upload) {
  347. if (abuf) efree(abuf);
  348. abuf = estrndup(param, strlen(param)-array_len);
  349. snprintf(lbuf, llen, "%s_name[%s]", abuf, array_index);
  350. } else {
  351. snprintf(lbuf, llen, "%s_name", param);
  352. }
  353. #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
  354. if (php_mb_encoding_translation(TSRMLS_C)) {
  355. if (num_vars>=num_vars_max){
  356. php_mb_gpc_realloc_buffer(&val_list, &len_list, &num_vars_max,
  357. 1 TSRMLS_CC);
  358. }
  359. val_list[num_vars] = filename;
  360. len_list[num_vars] = strlen(filename);
  361. num_vars++;
  362. if(php_mb_gpc_encoding_detector(val_list, len_list, num_vars, NULL TSRMLS_CC) == SUCCESS) {
  363. str_len = strlen(filename);
  364. php_mb_gpc_encoding_converter(&filename, &str_len, 1, NULL, NULL TSRMLS_CC);
  365. }
  366. s = php_mb_strrchr(filename, ‘\‘ TSRMLS_CC);
  367. if ((tmp = php_mb_strrchr(filename, ‘/‘ TSRMLS_CC)) > s) {
  368. s = tmp;
  369. }
  370. num_vars--;
  371. goto filedone;
  372. }
  373. #endif
  374. /* The check should technically be needed for win32 systems only where
  375. * it is a valid path separator. However, IE in all it‘s wisdom always sends
  376. * the full path of the file on the user‘s filesystem, which means that unless
  377. * the user does basename() they get a bogus file name. Until IE‘s user base drops
  378. * to nill or problem is fixed this code must remain enabled for all systems.
  379. */
  380. s = strrchr(filename, ‘\‘);
  381. if ((tmp = strrchr(filename, ‘/‘)) > s) {
  382. s = tmp;
  383. }
  384. #ifdef PHP_WIN32
  385. if (PG(magic_quotes_gpc)) {
  386. s = s ? s : filename;
  387. tmp = strrchr(s, ‘‘‘);
  388. s = tmp > s ? tmp : s;
  389. tmp = strrchr(s, ‘"‘);
  390. s = tmp > s ? tmp : s;
  391. }
  392. #endif
  393. #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
  394. filedone:
  395. #endif
  396. if (!is_anonymous) {
  397. if (s && s > filename) {
  398. safe_php_register_variable(lbuf, s+1, strlen(s+1), NULL, 0 TSRMLS_CC);
  399. } else {
  400. safe_php_register_variable(lbuf, filename, strlen(filename), NULL, 0 TSRMLS_CC);
  401. }
  402. }
  403. /* Add $foo[name] */
  404. if (is_arr_upload) {
  405. snprintf(lbuf, llen, "%s[name][%s]", abuf, array_index);
  406. } else {
  407. snprintf(lbuf, llen, "%s[name]", param);
  408. }
  409. if (s && s > filename) {
  410. register_http_post_files_variable(lbuf, s+1, http_post_files, 0 TSRMLS_CC);
  411. } else {
  412. register_http_post_files_variable(lbuf, filename, http_post_files, 0 TSRMLS_CC);
  413. }
  414. efree(filename);
  415. s = NULL;
  416. /* Possible Content-Type: */
  417. if (cancel_upload || !(cd = php_mime_get_hdr_value(header, "Content-Type"))) {
  418. cd = "";
  419. } else {
  420. /* fix for Opera 6.01 */
  421. s = strchr(cd, ‘;‘);
  422. if (s != NULL) {
  423. *s = ‘‘;
  424. }
  425. }
  426. /* Add $foo_type */
  427. if (is_arr_upload) {
  428. snprintf(lbuf, llen, "%s_type[%s]", abuf, array_index);
  429. } else {
  430. snprintf(lbuf, llen, "%s_type", param);
  431. }
  432. if (!is_anonymous) {
  433. safe_php_register_variable(lbuf, cd, strlen(cd), NULL, 0 TSRMLS_CC);
  434. }
  435. /* Add $foo[type] */
  436. if (is_arr_upload) {
  437. snprintf(lbuf, llen, "%s[type][%s]", abuf, array_index);
  438. } else {
  439. snprintf(lbuf, llen, "%s[type]", param);
  440. }
  441. register_http_post_files_variable(lbuf, cd, http_post_files, 0 TSRMLS_CC);
  442. /* Restore Content-Type Header */
  443. if (s != NULL) {
  444. *s = ‘;‘;
  445. }
  446. s = "";
  447. /* Initialize variables */
  448. add_protected_variable(param TSRMLS_CC);
  449. magic_quotes_gpc = PG(magic_quotes_gpc);
  450. PG(magic_quotes_gpc) = 0;
  451. /* if param is of form xxx[.*] this will cut it to xxx */
  452. if (!is_anonymous) {
  453. safe_php_register_variable(param, temp_filename, strlen(temp_filename), NULL, 1 TSRMLS_CC);
  454. }
  455. /* Add $foo[tmp_name] */
  456. if (is_arr_upload) {
  457. snprintf(lbuf, llen, "%s[tmp_name][%s]", abuf, array_index);
  458. } else {
  459. snprintf(lbuf, llen, "%s[tmp_name]", param);
  460. }
  461. add_protected_variable(lbuf TSRMLS_CC);
  462. register_http_post_files_variable(lbuf, temp_filename, http_post_files, 1 TSRMLS_CC);
  463. PG(magic_quotes_gpc) = magic_quotes_gpc;
  464. {
  465. zval file_size, error_type;
  466. error_type.value.lval = cancel_upload;
  467. error_type.type = IS_LONG;
  468. /* Add $foo[error] */
  469. if (cancel_upload) {
  470. file_size.value.lval = 0;
  471. file_size.type = IS_LONG;
  472. } else {
  473. file_size.value.lval = total_bytes;
  474. file_size.type = IS_LONG;
  475. }
  476. if (is_arr_upload) {
  477. snprintf(lbuf, llen, "%s[error][%s]", abuf, array_index);
  478. } else {
  479. snprintf(lbuf, llen, "%s[error]", param);
  480. }
  481. register_http_post_files_variable_ex(lbuf, &error_type, http_post_files, 0 TSRMLS_CC);
  482. /* Add $foo_size */
  483. if (is_arr_upload) {
  484. snprintf(lbuf, llen, "%s_size[%s]", abuf, array_index);
  485. } else {
  486. snprintf(lbuf, llen, "%s_size", param);
  487. }
  488. if (!is_anonymous) {
  489. safe_php_register_variable_ex(lbuf, &file_size, NULL, 0 TSRMLS_CC);
  490. }
  491. /* Add $foo[size] */
  492. if (is_arr_upload) {
  493. snprintf(lbuf, llen, "%s[size][%s]", abuf, array_index);
  494. } else {
  495. snprintf(lbuf, llen, "%s[size]", param);
  496. }
  497. register_http_post_files_variable_ex(lbuf, &file_size, http_post_files, 0 TSRMLS_CC);
  498. }
  499. efree(param);
  500. }
  501. }
  502. fileupload_done:
  503. if (php_rfc1867_callback != NULL) {
  504. multipart_event_end event_end;
  505. event_end.post_bytes_processed = SG(read_post_bytes);
  506. php_rfc1867_callback(MULTIPART_EVENT_END, &event_end, &event_extra_data TSRMLS_CC);
  507. }
  508. SAFE_RETURN;
  509. }

上传文件,提示文件不存在的解决方法,布布扣,bubuko.com

时间: 2024-10-22 19:34:57

上传文件,提示文件不存在的解决方法的相关文章

asp.net 文件上传出错:Maximum request length exceeded 解决方法

<configuration>    <system.web>               <httpRuntime maxRequestLength="102400" useFullyQualifiedRedirectUrl="true" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="10

HTML5上传视频无法播放以及兼容的解决方法

一.视频无法播放原因分析 1.路径不对 <video width="100%" height="100%" controls="controls">   <source src="images/apply.mp4" type="video/mp4"></source>  </video> 在images前面不加斜杠,使用相对路径,不要使用绝对路径 2.视频格式

Chrome浏览器点击 input file上传按钮时延迟3-5秒的解决方法

1.  Google chrome 浏览器在52版本之后出现一个bug,就是点击 input file上传按钮时反应很慢,需要等待3-5秒种之后才能弹出选择文件的对话框.比如 windows里可能是这样: MAC里可能是这样:

用git上传时出现411 Length Required的解决方法

今天用eclipse插件版的git上传文件,可是以前怎么传都是好的,今天就遇到了 411 Length Required 很是奇怪,上网一查发现是git有默认上传大小,如果上传的文件大于10M就会出现这个问题,好了,下面我改一下 Eclipse>Preferences>Team>Git>Configuration>Add Entry 输入 http.postBuffer做为key,1000000000做为value (1G大小应该够了) 好了,修改完后,再去提交一下,成功了吧

destoon b2b 不能上传图和预览图片的解决方法

使用destoon的站长有时候因为网站搬家或者重新安装后,发现网站后台或者前台发布信息时不能上传图片,以及自己也不能操作了,这个先判断是不是权限问题,之后再判断其他的,可是权限没有任何的问题的,那么这个问题就在于程序方面的了,因为同一个服务器的话那么打开站点正常以及ftp上传正常的话,那么这个问题就可以说百分十九十是程序方面的问题了. 这个问题的原因是由于一个js文件命名的大小写导致的这个问题的发生,具体的问题是,点击上传图片没有任何的反映,就是加载了没有弹出来,那么这个时候可以发现一个/fil

IE浏览器下上传控件file出现光标的解决方法

<div class='upload-box'> <div class="input-group file-caption-main"> <div tabindex="500" class="btn btn-primary btn-file"> <input id="material-english" class='materials' name="material-engl

ASP.NET 使用js插件出现上传较大文件失败的解决方法(ajaxfileupload.js第一弹)

在写这篇的时候本来想把标题直接写成报错的提示,如下: "SecurityError:Blocked a frame with origin "http://localhost:55080" from accessing a cross-origin frame." 但是有点长,会显示不全,就想还是换一下吧,想了一下 "ASP.NET 上传过大图片或文件报错解决办法", 然后当我写完这个题目之后,我觉得这篇文章好像根本没有写的必要,估计看完题目就会

ASP.NET 使用ajaxupload.js插件出现上传较大文件失败的解决方法

在网上下载了一个ajaxupload.js插件,用于无刷新上传图片使的,然后就按照demo的例子去运行了一下,上传啊什么的都OK,但是正好上传的示例图片有一个比较大的,4M,5M的样子,然后上传就会报上面的错误. 单纯看我的描述,明显发现就是图片较大的原因,可能很快就会想到web.config的配置问题上,但是当我是当局者的时候,就没有那么灵光了,因为有提示错误,就有去百度一下,结果查到是什么“跨域调函数”的问题,至此,这个问题我探究的方向已经走偏. 虽然问题提示当中没有明显的说出是跟上传图片的

ASP.NET 使用ajaxfileupload.js插件出现上传较大文件失败的解决方法(ajaxfileupload.js第一弹)

在写这篇的时候本来想把标题直接写成报错的提示,如下: “SecurityError:Blocked a frame with origin "http://localhost:55080" from accessing a cross-origin frame.” 但是有点长,会显示不全,就想还是换一下吧,想了一下 “ASP.NET 上传过大图片或文件报错解决办法”, 然后当我写完这个题目之后,我觉得这篇文章好像根本没有写的必要,估计看完题目就会想到关于web.config配置的方面了

支持多文件上传的jQuery文件上传插件Uploadify

支持多文件上传的jQuery文件上传插件Uploadify,目前此插件有两种版本即Flash版本和HTML5版本,对于HTML5版本会比较好的支持手机浏览器,避免苹果手机Safari浏览器不支持Flash,主要特性:支持多文件上传.HTML5版本可拖拽上传.实时上传进度条显示.强大的参数定制功能,如文件大小.文件类型.按钮图片定义.上传文件脚本等. Flash版本使用方法: 1.加载JS和CSS ? 1 2 3 <script src="jquery/1.7.1/jquery.min.js