tags:

views:

140

answers:

3

Hello guys

I have created a PHP script to upload a file, unfortunately I don't have permission to save files on the disk. I have to upload an excel file (using phpexcel), then I have to read all the rows in the file and save to disk, Is there any way for me to process this file without saving to disk, I tried to read $_FILES['file1']['tmp_name'] but it doesn't work.

could u please suggest a method to process this file

Thank you for the consideration

+2  A: 

By "save to disk" you mean to send it back to the user for him to download it?

Usually, you shall have write access to (at least) the PHP temporary directory. Have you tried whether the form and script work in a local environment? Maybe there is something elso wrong with the upload?!

Finally: Why so you not have the persmission to save files? Are you allowed to create a subdirectory below you PHP file (via FTP) and give that one full permissions?

BurninLeo
+1: The "why" is an important question here. This sounds like a serious misconfiguration.
Pekka
+2  A: 

I tried to read $_FILES['file1']['tmp_name']

most probably you have just encountered an error.
that happens to beginner programmers very often

you have to repair that error instead of looking for odd workarounds.
Start from checking $_FILES['file1']['error']

what does

var_dump($_FILES['file1']['error']);

say?

Col. Shrapnel
The "newbie programmers" comment is maybe not by everyone's taste, but this is a very constructive answer. Why the downvote?
Pekka
if a word "newbie" sounds rude, I'm open to change it to any politically correct term.
Col. Shrapnel
I personally don't think it's rude, but maybe somebody overly sensitive did. That, or a revenge downvoter. Can't do anything about those...
Pekka
I didnt downvote, but I found the general tone somewhat derogatory. Though you do not explicitly say it, the answer can be read as *"You cant get it to work, so you're a noob. And your attempt at fixing the issue is obviously stupid"*. This is quite often the case with answers and comments of yours. They carry good information, but often they come across with an elitist attitude. Apparently, I'm not the only thinking so because I find them flagged as offensive in the Moderator Tools quite often. It's just that I have accepted Col Shrapnel uses words like Shrapnel and dont bother.
Gordon
@Col. Shrapnel - I see nothing wrong with this post in its current form. I think its also very constructive to point out that a mistake is made by many new / inexperienced programmers. To me, that reads "Don't feel bad, many people just learning make the same mistake", so +1.
Tim Post
A: 

Instead of sending your files with a form (multidata over HTTP POST), you can send your files with a little bit of Javascript with the HTTP PUT method to your server. This scenario is described in the official documentation of PHP -> PUT method support. Due some restrictions described in the documentation you have to do some workarounds to be able to work it properly.

You can read the direct input stream from your Webserver. The data will be piped from your Webserver to your PHP programm and will be only saved in memory. To do a PUT Ajax call with jQuuery was answered here. You can use a jQuery upload plugin like Uploadify.

DrDol
lol that's really helpful answer :)
Col. Shrapnel
What do you mean by this. What's wrong with my answer?
DrDol