Skip to main content
there is no need to put "resolved" in the title
Source Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284

Resolved - Copy the images to the public folder after form submit with PLupload in a custom module

Happy new year !

I have a custom module to create galleries using PLupload to upload multiple files. These files have a ".tmp" extension in my "/tmp" folder.

Here is an extract of my $form_state['values']  :

[0] => Array( [tmppath] => temporary://p17g31n52jo4fvj31ds01efd189b4.tmp [tmpname] => p17g31n52jo4fvj31ds01efd189b4.tmp [name] => photo_1.jpg [status] => done ) 

How do I save the files in my public folder with the good extension (like .jpg)  ? I've tried to useusing file_save_upload(), or file_copy() but without success.

Can anyone can help me  ? I'm sure so thanks in advance...

Regards,

Edit (@Seth's comment) : I'm I'm on a local server (wamp) as administrator with all permissions. The folders (tmp and site/default) are writable.

I copy here some extracts of my code...

hook_form() :

$form['create']['photos'] = array( '#type' => 'plupload', '#title' => 'Photos', '#upload_validators' => array( 'file_validate_extensions' => array('jpg jpeg gif png'), ), '#plupload_settings' => array( 'runtimes' => 'html5', 'chunk_size' => '1mb', ), ); 

hook_form_validate() :

$file = file_save_upload('photos', array( 'file_validate_is_image' => array(), 'file_validate_extensions' => array('png gif jpg jpeg'), )); if ($file) { if ($file = file_move($file, 'public://')) { $form_state['storage']['file'] = $file; } else { form_set_error('file', t('Failed to write the uploaded file the site\'s file folder.')); } } else { form_set_error('file', t('No file was uploaded.')); } 

It's return No file was uploaded..It returns "No file was uploaded." I don't understand what iI should put as first arguments to the file_save_upload function.

Hope that someone helps me with these infos.

Resolved - Copy the images to the public folder after form submit with PLupload in a custom module

Happy new year !

I have a custom module to create galleries using PLupload to upload multiple files. These files have a ".tmp" extension in my "/tmp" folder.

Here is an extract of my $form_state['values']  :

[0] => Array( [tmppath] => temporary://p17g31n52jo4fvj31ds01efd189b4.tmp [tmpname] => p17g31n52jo4fvj31ds01efd189b4.tmp [name] => photo_1.jpg [status] => done ) 

How do I save the files in my public folder with the good extension (like .jpg)  ? I've tried to use file_save_upload(), file_copy() but without success.

Can anyone can help me  ? I'm sure so thanks in advance...

Regards,

Edit (@Seth's comment) : I'm on a local server (wamp) as administrator with all permissions. The folders (tmp and site/default) are writable.

I copy here some extracts of my code...

hook_form() :

$form['create']['photos'] = array( '#type' => 'plupload', '#title' => 'Photos', '#upload_validators' => array( 'file_validate_extensions' => array('jpg jpeg gif png'), ), '#plupload_settings' => array( 'runtimes' => 'html5', 'chunk_size' => '1mb', ), ); 

hook_form_validate() :

$file = file_save_upload('photos', array( 'file_validate_is_image' => array(), 'file_validate_extensions' => array('png gif jpg jpeg'), )); if ($file) { if ($file = file_move($file, 'public://')) { $form_state['storage']['file'] = $file; } else { form_set_error('file', t('Failed to write the uploaded file the site\'s file folder.')); } } else { form_set_error('file', t('No file was uploaded.')); } 

It's return No file was uploaded... I don't understand what i should put as first arguments to the file_save_upload function.

Hope that someone helps me with these infos.

Copy the images to the public folder after form submit with PLupload in a custom module

I have a custom module to create galleries using PLupload to upload multiple files. These files have a ".tmp" extension in my "/tmp" folder.

Here is an extract of my $form_state['values']:

[0] => Array( [tmppath] => temporary://p17g31n52jo4fvj31ds01efd189b4.tmp [tmpname] => p17g31n52jo4fvj31ds01efd189b4.tmp [name] => photo_1.jpg [status] => done ) 

How do I save the files in my public folder with the good extension (like .jpg)? I've tried using file_save_upload() or file_copy() but without success.

Can anyone help me?

I'm on a local server (wamp) as administrator with all permissions. The folders (tmp and site/default) are writable.

I copy here some extracts of my code.

hook_form() :

$form['create']['photos'] = array( '#type' => 'plupload', '#title' => 'Photos', '#upload_validators' => array( 'file_validate_extensions' => array('jpg jpeg gif png'), ), '#plupload_settings' => array( 'runtimes' => 'html5', 'chunk_size' => '1mb', ), ); 

hook_form_validate() :

$file = file_save_upload('photos', array( 'file_validate_is_image' => array(), 'file_validate_extensions' => array('png gif jpg jpeg'), )); if ($file) { if ($file = file_move($file, 'public://')) { $form_state['storage']['file'] = $file; } else { form_set_error('file', t('Failed to write the uploaded file the site\'s file folder.')); } } else { form_set_error('file', t('No file was uploaded.')); } 

It returns "No file was uploaded." I don't understand what I should put as first arguments to the file_save_upload function.

Change the title to mark the post as resolved
Link

Resolved - Copy the images to the public folder after form submit with PLupload in a custom module

additional informations
Source Link

Happy new year !

I have a custom module to create galleries using PLupload to upload multiple files. These files have a ".tmp" extension in my "/tmp" folder.

Here is an extract of my $form_state['values'] :

[0] => Array( [tmppath] => temporary://p17g31n52jo4fvj31ds01efd189b4.tmp [tmpname] => p17g31n52jo4fvj31ds01efd189b4.tmp [name] => photo_1.jpg [status] => done ) 

How do I save the files in my public folder with the good extension (like .jpg) ? I've tried to use file_save_upload(), file_copy() but without success.

Can anyone can help me ? I'm sure so thanks in advance...

Regards,

Edit (@Seth's comment) : I'm on a local server (wamp) as administrator with all permissions. The folders (tmp and site/default) are writable.

I copy here some extracts of my code...

hook_form() :

$form['create']['photos'] = array( '#type' => 'plupload', '#title' => 'Photos', '#upload_validators' => array( 'file_validate_extensions' => array('jpg jpeg gif png'), ), '#plupload_settings' => array( 'runtimes' => 'html5', 'chunk_size' => '1mb', ), ); 

hook_form_validate() :

$file = file_save_upload('photos', array( 'file_validate_is_image' => array(), 'file_validate_extensions' => array('png gif jpg jpeg'), )); if ($file) { if ($file = file_move($file, 'public://')) { $form_state['storage']['file'] = $file; } else { form_set_error('file', t('Failed to write the uploaded file the site\'s file folder.')); } } else { form_set_error('file', t('No file was uploaded.')); } 

It's return No file was uploaded... I don't understand what i should put as first arguments to the file_save_upload function.

Hope that someone helps me with these infos.

Happy new year !

I have a custom module to create galleries using PLupload to upload multiple files. These files have a ".tmp" extension in my "/tmp" folder.

Here is an extract of my $form_state['values'] :

[0] => Array( [tmppath] => temporary://p17g31n52jo4fvj31ds01efd189b4.tmp [tmpname] => p17g31n52jo4fvj31ds01efd189b4.tmp [name] => photo_1.jpg [status] => done ) 

How do I save the files in my public folder with the good extension (like .jpg) ? I've tried to use file_save_upload(), file_copy() but without success.

Can anyone can help me ? I'm sure so thanks in advance...

Regards,

Happy new year !

I have a custom module to create galleries using PLupload to upload multiple files. These files have a ".tmp" extension in my "/tmp" folder.

Here is an extract of my $form_state['values'] :

[0] => Array( [tmppath] => temporary://p17g31n52jo4fvj31ds01efd189b4.tmp [tmpname] => p17g31n52jo4fvj31ds01efd189b4.tmp [name] => photo_1.jpg [status] => done ) 

How do I save the files in my public folder with the good extension (like .jpg) ? I've tried to use file_save_upload(), file_copy() but without success.

Can anyone can help me ? I'm sure so thanks in advance...

Regards,

Edit (@Seth's comment) : I'm on a local server (wamp) as administrator with all permissions. The folders (tmp and site/default) are writable.

I copy here some extracts of my code...

hook_form() :

$form['create']['photos'] = array( '#type' => 'plupload', '#title' => 'Photos', '#upload_validators' => array( 'file_validate_extensions' => array('jpg jpeg gif png'), ), '#plupload_settings' => array( 'runtimes' => 'html5', 'chunk_size' => '1mb', ), ); 

hook_form_validate() :

$file = file_save_upload('photos', array( 'file_validate_is_image' => array(), 'file_validate_extensions' => array('png gif jpg jpeg'), )); if ($file) { if ($file = file_move($file, 'public://')) { $form_state['storage']['file'] = $file; } else { form_set_error('file', t('Failed to write the uploaded file the site\'s file folder.')); } } else { form_set_error('file', t('No file was uploaded.')); } 

It's return No file was uploaded... I don't understand what i should put as first arguments to the file_save_upload function.

Hope that someone helps me with these infos.

Source Link
Loading