Jump to content

Problem with Uploading files using form


danylo

Recommended Posts

Hi,

 

what I want to do is upload files to my server. After clicking upload a pop-up window should appear doing all the processing and stating if it is successful. This works if I do it in the same window but opening a new window I seem to lose all the information from the POST. How can I keep this information?

 

<form enctype="multipart/form-data" action="javascript:action_prepaid('upload_captive.php');" method="POST">
		  <table width="100%"  border="0" cellspacing="0" cellpadding="4" align="left">    
		      <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
			  <tr><td size="35">Top Logo:</td><td><input name="uploadedfile1" type="file" /></td></tr>
			  <tr><td size="35">Bottom Logo:</td><td><input name="uploadedfile2" type="file" /></td></tr>
			  <tr><td size="35">Background Logo:</td><td><input name="uploadedfile3" type="file" /></td></tr>
			  <tr><td colspan="2"><input type="submit" class="loginsubmit" value="Upload" />   <input class="loginsubmit" name="reset" type="reset" value="Reset"> </td></tr>					      
		  </table>
		</form>

 

//performs the actions on the prepaid pages
function action_prepaid(url) {
var newwindow;

newwindow=window.open(url,'name','height=200,width=400');
if (window.focus) {newwindow.focus()}

}

 

If I did <form enctype="multipart/form-data" action="upload_captive.php" method="POST"> this would work but I do not want to do this as I want to stay on the current page (not bring me to the upload_captive.php page. This php file is just a script that processes the upload and nothing is shown there except upload successful/failed.

Thanks.

 

DAN

Link to comment
https://forums.phpfreaks.com/topic/55336-problem-with-uploading-files-using-form/
Share on other sites

if you are using a doctype that allows it you can use the target="_blank" attribute of the form and that will open a new window - just use a bit of js to resize the new window when its loads.

 

The alternative (and one that mnay will expect far more) is to simply stay in the same window.  Having a form left there and a new window opening can be quite annoying and then you have to do all the js work to update the html with any error reporting.

 

extra work is very dull - just let it do its stuff - its what most of us expect.

Hi,

I kept it in the same window by changing my js function to

function action_prepaid(url) {
jsphp_shtml('',url,'');

}

I'm not sure if I really need the 1st or 3rd parameters though so I just left them blank and the url is the upload_captive.php page. The only problem is that even keeping in the same window it doesn't seem to keep the values from the form. So the upload_captive.php file doesn't see anything and uploads nothing.

Just to recap: in the form action="upload_captive.php" will see what I uploaded and upload it properly but action="javascript:action_prepaid('upload_captive.php');" does not.

Thanks.

 

DAN

then don't use javascript...

 

there is no neccessity for js to be invovled for anything other than client side validation; which should be checked server side anyway just in case js iss off or hsa been tampered with.

 

I don't understand the obsession fo using javascript to do things that are handled perfectly well by good old html...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.