![]() |
Problem with file upload on edit page - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Problem with file upload on edit page (/showthread.php?tid=13153) |
Problem with file upload on edit page - El Forum - 11-12-2008 [eluser]opel[/eluser] I have been working on a cms for a small site and having a problem with the edit page and file upload. My edit page shows the currently uploaded file and option to upload a new file. THe problem occurs if I submit an edit page without a putting a new file in the "file" field as it tried to do the upload in the model even though I have put if not null. My code is below, could anyone advise where I am going wrong please ? THanks Code: function update() Problem with file upload on edit page - El Forum - 11-13-2008 [eluser]Flemming[/eluser] you could try: Code: if($_FILES['myfile']['name'] != "") Code: if(!empty($_FILES['myfile']) Problem with file upload on edit page - El Forum - 11-13-2008 [eluser]opel[/eluser] neither of these worked I'm afraid ![]() Problem with file upload on edit page - El Forum - 11-14-2008 [eluser]Flemming[/eluser] hmm .. ok, what about simply Code: if(!empty($_FILES)) or perhaps you could do Code: if(empty($_FILES['myfile'])) $noUpload = True; Problem with file upload on edit page - El Forum - 11-14-2008 [eluser]El EmiZ[/eluser] Try. Code: if ($_FILES['myfile']['error'] == UPLOAD_ERR_OK) { Hmmm... Just a small precaution, but make sure that in the database table your 'file' field is "NULL" and no "NOT NULL". =) Good luck. |