function form_example_tutorial_10($form_state) { // If you are familiar with how browsers handle files, you know that // enctype="multipart/form-data" is required. Drupal takes care of that, so // you don't need to include it yourself. $form['file'] = array( '#type' => 'file', '#title' => t('Image'), '#description' => t('Upload a file, allowed extensions: jpg, jpeg, png, gif'), // '#default_value' => ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; } /** * Validate handler for form_example_tutorial_10(). */ function form_example_tutorial_10_validate($form, &$form_state) { $file = file_save_upload('file', array( 'file_validate_is_image' => array(), // Validates file is really an image. 'file_validate_extensions' => array('png gif jpg jpeg'), // Validate extensions. )); // If the file passed validation: if ($file) { // Move the file, into the Drupal file system if ($file = file_move($file, 'public://')) { // Save the file for use in the submit handler. $form_state['storage']['file'] = $file; } else { form_set_error('file', t('Failed to write the uploaded file to the site\'s file folder.')); } } else { form_set_error('file', t('No file was uploaded.')); } } /** * Submit handler for form_example_tutorial_10(). */ function form_example_tutorial_10_submit($form, &$form_state) { $file = $form_state['storage']['file']; // We are done with the file, remove it from storage. unset($form_state['storage']['file']); // Make the storage of the file permanent $file->status = FILE_STATUS_PERMANENT; // Save file status. file_save($file); // Set a response to the user. drupal_set_message(t('The form has been submitted and the image has been saved, filename: @filename.', array('@filename' => $file->filename))); }
相关推荐
java文件上传 下载
源代码 上传文件和上传图片
本文实例讲述了PHP实现通过CURL上传文件功能。分享给大家供大家参考,具体如下: ... 下面我们以一个例子来展示这个过程。 ... this is a file for test hello PythonTab!...为了把这个文件上传给服务端的脚本http://you
自动上传文件,样式美化,input file选择文件之后自动上传(样式自定义美化),$.ajaxFileUpload自动上传文件。不会包教会。你值得拥有!
注意:input[type=file] 标签中的属性accept=application/msword,application/pdf 在pc上正常,但是在手机ios和android上这个文件格式限制会被忽略,所以需要在js中增加格式的判断,以及对应显示样式的设置.(我也是刚...
CloseableHttpClient调用三方HTTP接口,带有FILE文件类型参数
基于SpringBoot的文件上传系统,前后端分离,单文件上传,多文件上传,大文件上传,断点续传,文件秒传,图片上传 项目经过严格测试,确保可以运行! 采用前后端分离的方式进行开发,实现了几种常用的文件上传功能...
jquery的文件上传插件,简单好用,只需要在页面头部包含jquery的js文件和filestyle.js,设置样式即可使用,具体请参照demo,很简单实用。
flask-file-uploader, 在 python Flask 上使用jQuery文件上传,上传的上传网站脚本 flask-file-uploader描述File文件,支持 python Flask 和 jQuery-File-Upload插件,包括多个文件选择,拖放支持,进度条,验证和...
js input file多个文件上传功能是一款可input上传图片和input file多个文件上传功能特效代码
今天小编就为大家分享一篇Django处理文件上传File Uploads的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
网页文件上传控件,支持4G以上超大文件传输,随时停止,支持断点续传功能,支持用户自制界面。 与您的网页系统进行无缝整合,使您的系统可自如地上传文件,并能及时获取与上传文件相关的各种信息。控件提供各种...
之前发布一个大文件上传,但是问题太多,此版本相对上一个稳定得多 1,将压缩包里的 php_uploadprogress.dll 文件复制到你的PHP 安装目录里的扩展库文件夹 就是 ext文件夹下面 2,在你的服务器上随便一个地方(最好...
这是一个隐藏 html file 控件上传图标文件的示例,功能齐全,包括: 1. 隐藏 file 控件 2. 上传文件不刷新整个页面 3. 上传成功后后台调用前台的js函数,更新 img 中的src,实现用上传图标文件 更新 img 中图片的...
css以及js
本文实例讲述了C#实现HTTP上传文件的方法。分享给大家供大家参考。具体实现方法如下: 发送文件代码如下: 代码如下: /// /// Http上传文件 /// public static string HttpUploadFile(string url, string ...
angularjs 大文件上传插件ng-file-upload第三方编写的大文件上传插件,包括Demo和所有的ng-file-upload相关JS文件
asp简单文件上传源码 文件1.上传界面文件 upload.htm 文件2.保存上传文件 SaveFile.asp
一个file控件实现上传多个文件到服务器,并且导入数据库中并且页面无刷新(附带所需要的js和java包)
Multiple File Upload - jQuery文件上传插件