Jump to content

[SOLVED] Ajax + Php


Michdd

Recommended Posts

Not really, the problem is javascript can't control the file input (for security reasons), however a workaround would be to put the form in a iframe allows you to stay on the same page.

if your also aiming for a processbar then again no luck php can't read how much data has been processed, a workaround for this is CGI script. and a small ajax to read the data recieved

Link to comment
Share on other sites

The main point would be to upload/process it without reloading the page. I will have 2 methods of uploading images, from a URL, or from your computer. The URL one works fine because I just send the URL of the input file through ajax to another php file for processing. But this obviously won't work for uploading from a computer. I was also thinking about using an iframe with 0 width/height/border but how would I get it to submit the information to the iframe? If I could do it using GET variables then I could just change the source of the iframe.. but since it'll be using post, I'm a bit confused.

Link to comment
Share on other sites

Their are other ways but they get a little bit complex, the iframe will still work in a table

take a look at this (it basically used javascript to put the iframe in place)

I was actually just looking at the same thing myself. Thanks.

Link to comment
Share on other sites

I thought I had everything figured out.. But isn't it supposed to send the information to the file? I tried echoing something out like:

 

echo $_FILES['userfile']['name'];

 

Where the form says:

 

<label for="file">File:</label> <input type="file" name="userfile" id="file" />

 

But it's not sending the information..

 

Edit: I forgot:

enctype="multipart/form-data"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.