I'm using the jquery validator to validate that my form, but it doesn't upload the file properly.
If I add enctype="multipart/form-data" to the form it uploads the file but
doesn't grab the form data passed.
Well I solved the problem I changed.
$the_field = $_REQUEST['field'];
$the_field = $_FILES['field']['name'];
Related
I have a form as:<form action="test.php" method="post" name="testForm">
And I have validations of image upload in another file "upload.php" which has some code as:
if (in_array($_FILES['myfile']['type'], $types)) {
if(filesize($_FILES['myfile']['tmp_name']) < $max_size) {
$destination_path = getcwd().DIRECTORY_SEPARATOR."images".DIRECTORY_SEPARATOR;
So is there any way by which I can call the upload.php file without altering test.php file from form action attribute and perform my image upload validations.
you could use
include('upload.php');
OR
by using copy of the function into test.php
For the record, it would actually be better to use a jquery function which would submit the form to upload.php and then to test.php.
If you can alter the HTML code of your form, you could post to upload.php instead of test.php and then repost from upload.php to test.php (using CURL, for example)
If I get you right there are many ways. I recommend reading a bit in the manual:
include
functions.
class
filter
i need to upload a file doc or pdf or rich text through jquery and smarty
i try to pass the file in jquery is given below
window.location.href= sitePath+'download?p='+$('#file').val();
but the p doesn't have value. how to get the file path or name and how can stored in server
in controller i write just pass the query to model is given below
$model=new download();
$id=$model->upload($param);
and i can't develop the model code....
please help me
You can't send files like that.
You should either submit a form with enctype="multipart/form-data" or use some AJAX uploader (which uses form submit to iframe and then stores a file using PHP script).
EDIT: Some references
http://www.w3schools.com/php/php_file_upload.asp - tutorial on how to upload a file using PHP
http://valums.com/ajax-upload/ - example of ajax uploader.
EDIT2: The problem is not with your model code but with the way you try to submit a file.
<form action="upload_file.php" method="post" enctype="multipart/form-data">
Above is the line for a form to upload a file using php.
If i use the form as I wrote above I can get the various properties of the file to be uploaded from upload_file.php page.
Using jquery $.post , how can I do the same thing in upload_file.php ?
I googled but can't find the exact snippet of code necessary here.
Uploading images using jquery's ajax methods is a pain, generally involving dynamically creating an iframe and submitting a form inside it. I usually use this plugin: http://plugins.jquery.com/project/jquery-upload
You can write some php to echo the uploaded image data as a json object, which you can access once the upload is complete through the plugin.
I have a image upload form which adds an image to my server, although I'm wanting to load the information through jQuery ajax so the form doesn't refresh on submit.
At the moment I have
$('.img-form').submit(function(e) {
e.preventDefault();
$.post(document.href, $(".img-form").serialize());
});
Which seems to post the document, although i need to get it to call my ImageUpload() function from the PHP once I've pressed the submit.
My php function is called something like this,
<?php $Users->TutorialImageUpload(); ?>
If I understood correctly, you wish to upload an image without refreshing the page, and call your imageUpload() function.
As mentioned in the comments, you cannot upload in such a manner, however, what you could do
is put your upload form and code in a seperate php file and include it in the page as an iframe. This would upload your files withough refreshing the page.
I want to upload a file from a GWT form panel to php server;
FormPanel formPanel = new FormPanel();
formPanel.setAction("http://www.digicom.vacau.com/FileUpload.php");
formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
formPanel.setMethod(FormPanel.METHOD_POST);
In the form panel, I'm placing a file upload widget and submit button. But it is not uploading. Can someone help??
You still need to attach a (absolute or vertical)panel to the formPanel and attach a FileUpload widget to that. Don't forget to use formPanel.setWidget(Panel panel)!
Take a look at this code:
http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/user/client/ui/FormPanel.html