4

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
  • 2
    You are not allowed to save data anywhere on the server? Why? That sounds like a misconfiguration. Commented Aug 7, 2010 at 10:02
  • 1
    You need to be more specific. Programming is all about the details. As Pekka says, tell us why you " don't have permission to save files on the disk". Also, when you say " it doesn't work." how doesn't it work? Please describe its behaviour, listing any error messages or other output. Help us to help you. Commented Aug 8, 2010 at 8:14

3 Answers 3

4

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?

Sign up to request clarification or add additional context in comments.

1 Comment

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

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?

5 Comments

The "newbie programmers" comment is maybe not by everyone's taste, but this is a very constructive answer. Why the downvote?
if a word "newbie" sounds rude, I'm open to change it to any politically correct term.
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...
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.
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.
0

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 jQuery was answered here. You can use a jQuery upload plugin like Uploadify.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.